Skip to content

Commit

Permalink
📝 [DOC] Reorder loadinfrastructure arguments list
Browse files Browse the repository at this point in the history
  • Loading branch information
marcantoinedupre committed Nov 14, 2023
1 parent d22d8f9 commit ab17fa0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 45 deletions.
78 changes: 47 additions & 31 deletions docs/install/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,61 +460,77 @@ Import Infrastructure

::

usage: manage.py loadinfrastructure [-h] [--use-structure] [--encoding ENCODING] [--name-field NAME_FIELD]
[--type-field TYPE_FIELD] [--category-field CATEGORY_FIELD] [--condition-field CONDITION_FIELD]
[--structure-field STRUCTURE_FIELD] [--description-field DESCRIPTION_FIELD] [--year-field YEAR_FIELD]
[--type-default TYPE_DEFAULT] [--category-default CATEGORY_DEFAULT] [--name-default NAME_DEFAULT]
[--condition-default CONDITION_DEFAULT] [--structure-default STRUCTURE_DEFAULT]
[--description-default DESCRIPTION_DEFAULT] [--eid-field EID_FIELD] [--year-default YEAR_DEFAULT] [--version]
[-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
[--skip-checks] point_layer

Load a layer with point geometries and import features as infrastructures objects (expected formats: shapefile or geojson)
usage: manage.py loadinfrastructure [-h] [--use-structure] [--encoding ENCODING]
[--name-field NAME_FIELD] [--name-default NAME_DEFAULT]
[--type-field TYPE_FIELD] [--type-default TYPE_DEFAULT]
[--category-field CATEGORY_FIELD] [--category-default CATEGORY_DEFAULT]
[--condition-field CONDITION_FIELD] [--condition-default CONDITION_DEFAULT]
[--structure-field STRUCTURE_FIELD] [--structure-default STRUCTURE_DEFAULT]
[--description-field DESCRIPTION_FIELD] [--description-default DESCRIPTION_DEFAULT]
[--year-field YEAR_FIELD] [--year-default YEAR_DEFAULT]
[--eid-field EID_FIELD]
[--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback]
[--no-color] [--force-color] [--skip-checks]
point_layer

Load a layer with point geometries and import features as infrastructures objects
(expected formats: shapefile or geojson)

positional arguments:
point_layer

optional arguments:
-h, --help show this help message and exit
--use-structure If set the given (or default) structure is used to select or create conditions and types of infrastructures.
--use-structure
If set the given (or default) structure is used to select or create
conditions and types of infrastructures.
--encoding ENCODING, -e ENCODING
File encoding, default utf-8
--name-field NAME_FIELD, -n NAME_FIELD
The field to be imported as the `name` of the infrastructure
--name-default NAME_DEFAULT
Default name for all infrastructures, fallback for entries without a name
--type-field TYPE_FIELD, -t TYPE_FIELD
The field to select or create the type value of the infrastructure (field `InfrastructureType.label`)
--category-field CATEGORY_FIELD, -i CATEGORY_FIELD
The field to select or create the type value of the infrastructure (field `InfrastructureType.type`)
--condition-field CONDITION_FIELD, -c CONDITION_FIELD
The field to select or create the condition value of the infrastructure (field `InfrastructureCondition.label`)
--structure-field STRUCTURE_FIELD, -s STRUCTURE_FIELD
The field to be imported as the structure of the infrastructure
--description-field DESCRIPTION_FIELD, -d DESCRIPTION_FIELD
The field to be imported as the description of the infrastructure
--year-field YEAR_FIELD, -y YEAR_FIELD
The field to be imported as the `implantation_year` of the infrastructure
The field to select or create the type value of the infrastructure
(field `InfrastructureType.label`)
--type-default TYPE_DEFAULT
Default type for all infrastructures, fallback for entries without a type.
--category-field CATEGORY_FIELD, -i CATEGORY_FIELD
The field to select or create the type value of the infrastructure
(field `InfrastructureType.type`)
--category-default CATEGORY_DEFAULT
Default category for all infrastructures, "B" by default. Fallback for entries without a category
--name-default NAME_DEFAULT
Default name for all infrastructures, fallback for entries without a name
Default category for all infrastructures, "B" by default. Fallback for entries
without a category
--condition-field CONDITION_FIELD, -c CONDITION_FIELD
The field to select or create the condition value of the infrastructure
(field `InfrastructureCondition.label`)
--condition-default CONDITION_DEFAULT
Default condition for all infrastructures, fallback for entries without a category
--structure-field STRUCTURE_FIELD, -s STRUCTURE_FIELD
The field to be imported as the structure of the infrastructure
--structure-default STRUCTURE_DEFAULT
Default Structure for all infrastructures
--description-field DESCRIPTION_FIELD, -d DESCRIPTION_FIELD
The field to be imported as the description of the infrastructure
--description-default DESCRIPTION_DEFAULT
Default description for all infrastructures, fallback for entries without a description
--eid-field EID_FIELD
External ID field
Default description for all infrastructures, fallback for entries
without a description
--year-field YEAR_FIELD, -y YEAR_FIELD
The field to be imported as the `implantation_year` of the infrastructure
--year-default YEAR_DEFAULT
Default year for all infrastructures, fallback for entries without a year
--eid-field EID_FIELD
The field to be imported as the `eid` of the infrastructure (external ID)
--version show program's version number and exit
-v {0,1,2,3}, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
Verbosity level; 0=minimal output,
1=normal output,
2=verbose output,
3=very verbose output
--settings SETTINGS
The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided,
the DJANGO_SETTINGS_MODULE environment variable will be used.
The Python path to a settings module, e.g. "myproject.settings.main".
If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable
will be used.
--pythonpath PYTHONPATH
A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
--traceback Raise on CommandError exceptions
Expand Down
29 changes: 15 additions & 14 deletions geotrek/infrastructure/management/commands/loadinfrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,38 @@ def add_arguments(self, parser):
help='File encoding, default utf-8')
parser.add_argument('--name-field', '-n', action='store', dest='name_field',
help='The field to be imported as the `name` of the infrastructure')
parser.add_argument('--name-default', action='store', dest='name_default',
help='Default name for all infrastructures, fallback for entries without a name')
parser.add_argument('--type-field', '-t', action='store', dest='type_field',
help='The field to select or create the type value of the infrastructure '
'(field `InfrastructureType.label`)')
parser.add_argument('--type-default', action='store', dest='type_default',
help="Default type for all infrastructures, fallback for entries without a type.")
parser.add_argument('--category-field', '-i', action='store', dest='category_field',
help='The field to select or create the type value of the infrastructure '
'(field `InfrastructureType.type`)')
parser.add_argument('--condition-field', '-c', action='store', dest='condition_field',
help='The field to select or create the condition value of the infrastructure '
'(field `InfrastructureCondition.label`)')
parser.add_argument('--structure-field', '-s', action='store', dest='structure_field',
help='The field to be imported as the structure of the infrastructure')
parser.add_argument('--description-field', '-d', action='store', dest='description_field',
help='The field to be imported as the description of the infrastructure')
parser.add_argument('--year-field', '-y', action='store', dest='year_field',
help='The field to be imported as the `implantation_year` of the infrastructure')
parser.add_argument('--type-default', action='store', dest='type_default',
help="Default type for all infrastructures, fallback for entries without a type.")
parser.add_argument('--category-default', action='store', dest='category_default',
help='Default category for all infrastructures, "B" by default. Fallback for entries '
'without a category', default='B')
parser.add_argument('--name-default', action='store', dest='name_default',
help='Default name for all infrastructures, fallback for entries without a name')
parser.add_argument('--condition-field', '-c', action='store', dest='condition_field',
help='The field to select or create the condition value of the infrastructure '
'(field `InfrastructureCondition.label`)')
parser.add_argument('--condition-default', action='store', dest='condition_default',
help="Default condition for all infrastructures, fallback for entries without a category")
parser.add_argument('--structure-field', '-s', action='store', dest='structure_field',
help='The field to be imported as the structure of the infrastructure')
parser.add_argument('--structure-default', action='store', dest='structure_default',
help='Default Structure for all infrastructures')
parser.add_argument('--description-field', '-d', action='store', dest='description_field',
help='The field to be imported as the description of the infrastructure')
parser.add_argument('--description-default', action='store', dest='description_default', default="",
help='Default description for all infrastructures, fallback for entries without a description')
parser.add_argument('--eid-field', action='store', dest='eid_field', help='External ID field')
parser.add_argument('--year-field', '-y', action='store', dest='year_field',
help='The field to be imported as the `implantation_year` of the infrastructure')
parser.add_argument('--year-default', action='store', dest='year_default',
help='Default year for all infrastructures, fallback for entries without a year')
parser.add_argument('--eid-field', action='store', dest='eid_field',
help='The field to be imported as the `eid` of the infrastructure (external ID)')

def handle(self, *args, **options):
verbosity = options.get('verbosity')
Expand Down

0 comments on commit ab17fa0

Please sign in to comment.