Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
.coverage

.idea/
all-tests.cmd
run-all-tests.cmd
htmlcov/
mapactionpy_arcpro/tests/test_data/output*
mapactionpy_arcpro/tests/test_data/output_arcgis_10_6_reference_landscape_bottom.mxd
mapactionpy_arcpro/tests/test_data/arcgis_10_6_reference_landscape_bottom.json
junit-reports/

.fake
.ionide
68 changes: 47 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,62 @@ os: linux
dist: xenial
jobs:
include:
- name: Python 3.7 on Windows
os: windows
language: shell
before_install:
- choco install python --version 3.7.0
- python -m pip install --upgrade pip
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
- name: Python 3.6 on Windows
os: windows
language: shell
before_install:
- choco install python --version 3.6.8
- python -m pip install --upgrade pip
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
- name: Python 3.7 on Xenial Linux
python: 3.7
# This is the target environment
- name: "Python 2.7 on Windows"
os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python2
- python -m pip install --upgrade pip
- pip install mock
env: PATH=/c/Python27:/c/Python27/Scripts:$PATH
# Only required becuase deployto to PyPi appears to work better on a linux VM.
- name: Python 3.6 on Xenial Linux
python: 3.6
allow_failures:
# None of the jobs below matter. They are included as a measure of how much work
# might be required at a future date to port this package to a different target GIS,
# operating system or python version.
#
# Python 3.7 is used by QGIS v3.12
- name: "Python 3.7 on Xenial Linux"
python: 3.7
# Python 3.6 is used by ArcGIS Pro v2.4
- name: "Python 3.6 on Xenial Linux"
python: 3.6 # Required for ArcGIS Pro v2.4

# Python 3.7 is used by QGIS v3.12
- name: "Python 3.7 on Windows"
os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python --version 3.7.0
- python -m pip install --upgrade pip
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
# Python 3.6 is used by ArcGIS Pro v2.4
- name: "Python 3.6 on Windows"
os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python --version 3.6.8
- python -m pip install --upgrade pip
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
# Python 2.7 is used by Arcpro

install:
- pip install -r requirements-dev.txt
- pip install python-coveralls
# - pip install .
- pip install .
script:
- flake8
deploy:
provider: pypi
username: __token__
username: asmith_mapaction
password:
secure: pIo/lXON3iG9FsQ4Qui1cTyE9x9M6f+hFWU+QeObWanLdmXfIjD0xDjVElHlCe6YOy8i5JbDhTvvWPhyfDjdBOqehPLIIYeaJRYSZHz2I1C3u0jHaD3uKPvKrGXXpx42ZO7D9ZlQp2ZTQIeFmdqGnF5zG/3YL6KsB5juOYidqLdRuIvJ/k2SXjpqkPgoFjwYC6qSPUnH2rDFvIQZP7q5pX1qxQTaHLpIGPlndVZjyHOT/5Js2iQw5Wn/fQDk3U4f8ZOCiMvRNRVE4tA3ZhyOG4rMmr4SZa683bGCTe86s746yGSVBXs+5PCatR/swZGPX6KuQnei+BHwGLGDRNYgcIYoiAXDAkAIyUJ+9KhAtDHljGKkdYhnjgxTAqwIz2jS0+bdC8MWGR1gdyJsUUt2XZsOwat93oR1r01gIZQLRn6F/00RmwreNTTmSzJkVieQc6ZASVfibEMVdivrlZYVamrjsneqZz26efi8tL+cTK5f+oWbhVn0Xcb/54LotOJB7l3db9kUjdDLY0YfWO+eYYEwBUuq03MNqH2N0AKA7RT/5URsC8CJmpvQ86h1s5N7g/UepXEEjCUtdg0pqVVRsqP2GvQvBYwySsisT2+82jfSCD5C4XgDLT4vkfYeWbGZizYMvIkJTSAWenip0e3sZofkce/rZxWiQ6USKSZa4S4=
distributions: sdist
secure: w+xquPzLTNX7aeFycj0m1znQJM6f3u55k67rF4kROBXPUnO0zv5iT7HgWIEpOMvGBXzs/TXmXApH4IG0vBQXP2vUTWmQVUswvqV0ojA0yl6NqPrTeHICBF0sk0Cbg8R07hZLbh6hjDo29EwikqsnEhMErBo4/PsRqN0hSxvY7CUwzPmBfibzpJ28NJ2QnbtLJEDvuiO8jayTS9/3JPKeHojgiZ4w+VyDOZ0Kn5Y1c6Z/hitxRVBo8tQ1CErJOwZlWQ4HaDaOazd2lEaH1BxCxqwgDFAco0Z2TrOcZXFDxjL9y+8MkA0wzfQirkzTiMz2NnuzmbRHzVIC6+4Is+iJwdolTK/u1/sJKKdofAJr/8t2eOHxtJOv66oa6QCTMFfcAEizJNHRw3x0k07XT9AGlRh7+xMovq7Tco5rHe8maeaBZPQhp0wkl9vzutLg07DpwuXFOh3PEfpvWig/KZT8n/QOe8KJi1WSrlsNjXzdEcjl01typ9HDUR4OhuRoHiwS1d9Ri3PUNCCGDk4oBehi/PTFDDbAMD1eusM6S9srwBv/KJMMeidfKYORpbq5iLX6hIUokOgQ5iTNN2nHAQjJoYVazj4MVQ9zxZFxSsGDHn+Gnmft67ok0L7DtgH1gcT0FnpLwuNPXBHAD90V7osb4KkttlKLzhWazufmOy2KP38=
distributions: "sdist"
skip_existing: true
cleanup: false
on:
all_branches: true
condition: ${TRAVIS_OS_NAME,,} =~ ^linux$ && ${TRAVIS_BRANCH,,} =~ ^(master|${TRAVIS_TAG,,})$
condition: ${TRAVIS_OS_NAME,,} =~ ^linux$ && ${TRAVIS_BRANCH,,} =~ ^(master|${TRAVIS_TAG,,})$
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Installing
---------
To install the lastest stable release via PyPi:
```
pip install mapactionpy-controller
pip install mapactionpy-arcpro
python -m pip install git+https://github.com/mapaction/mapactionpy_controller.git@occamlabsarcpro
python -m pip install git+https://github.com/mapaction/mapactionpy_arcpro.git@occamlabsarcpro
```

To install a specific version for testing see the relevant commandline from here:
Expand Down
2 changes: 1 addition & 1 deletion mapactionpy_arcpro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# from .map_layer import MapLayer
# from .layer_properties import LayerProperties
# from .map_recipe import MapRecipe
from .map_chef import MapChef
# from .map_chef import MapChef
# from .map_cookbook import MapCookbook
# from .map_report import MapReport
# from .map_result import MapResult
99 changes: 99 additions & 0 deletions mapactionpy_arcpro/arc_layer_dumper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import argparse
import os
import arcpy

# TODO: asmith 2020/03/03
# What is the purpose of this file? Is this a tool that is just used within the
# maintainance of the `default_crash_move_folder`? It's entirely legitimate if it
# is, but it would be interesting to consider whether it could be intergrated into
# the other tools better. For example could we dump the layer files to text files on
# each commit of the `default_crash_move_folder` and keep the output within the git
# repo. This would mean to would be easier to see *what* had changed when a binary
# layer file changes.


def is_valid_file(parser, arg):
if not os.path.exists(arg):
parser.error("The file %s does not exist!" % arg)
return False
else:
return arg


def is_valid_directory(parser, arg):
if os.path.isdir(arg):
return arg
else:
parser.error("The directory %s does not exist!" % arg)
return False


def get_layer_properties(file):
lyr = arcpy.mapping.Layer(file)
layerName = lyr.name.encode('utf-8').strip()

if lyr.supports("DEFINITIONQUERY"):
dq = lyr.definitionQuery.encode('utf-8').strip()
else:
dq = ""

lblclassNames = []
lblexpressions = []
lblsql = []
lblshow = False

if lyr.supports("LABELCLASSES"):
lblshow = lyr.showLabels
for lblClass in lyr.labelClasses:
if lblClass.showClassLabels:
lblclassNames.append(lblClass.className.encode(
'utf-8').strip())
lblexpressions.append(lblClass.expression.encode(
'utf-8').strip())
lblsql.append(lblClass.SQLQuery.encode('utf-8').strip())

return (layerName, dq, lblshow, lblclassNames, lblexpressions, lblsql)


def main(args):
args = parser.parse_args()
layerDirectory = args.layerDirectory

# r=root, d=directories, f = files
lyr_details = {}
for r, d, f in os.walk(layerDirectory):
for file in f:
if '.lyr' in file:
props = get_layer_properties(os.path.join(r, file))
lyr_details[file] = props

# Print one row per file:
print("One row per file")
print("fullPath|layerName|definitionQuery|lblshow|labelClassNameCount")
for file in lyr_details:
layerName, dq, lblshow, lblclassNames, lblexpressions, lblsql = lyr_details[file]
print("|".join(map(str, (file, layerName, dq, lblshow, len(lblclassNames)))))

print
print
print
print("Only show files with Label Classes enabled and one row per *Label Class*")
# Print one row per file:
print("fullPath|layerName|definitionQuery|lblshow|labelClassNameCount|labelClassExpression|labelClassSQLQuery|")
for file in lyr_details:
layerName, dq, lblshow, lblclassNames, lblexpressions, lblsql = lyr_details[file]
if len(lblclassNames):
for n, e, s in zip(lblclassNames, lblexpressions, lblsql):
print("|".join((file, layerName, dq, str(lblshow), n, e, s)))


if __name__ == '__main__':
parser = argparse.ArgumentParser(
# TODO: asmith 2020/03/03
# presumably "layer files" not "later files"?
description='Dumps the contents of later files.',
)
parser.add_argument("-ld", "--layerDirectory", dest="layerDirectory", required=True,
help="path to layer directory", metavar="FILE", type=lambda x: is_valid_directory(parser, x))
args = parser.parse_args()
main(args)
Loading