Skip to content

Commit

Permalink
Use BasicArgumentParser
Browse files Browse the repository at this point in the history
  • Loading branch information
invisibleroads committed Oct 24, 2016
1 parent 6f72427 commit cff8463
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
2 changes: 0 additions & 2 deletions cc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,13 @@ command_template = python estimate_grid_mv_line_budget_in_meters.py
--target_folder {target_folder}
--financing_year {financing_year}
--time_horizon_in_years {time_horizon_in_years}
--discount_rate_as_percent_of_cash_flow_per_year {discount_rate_as_percent_of_cash_flow_per_year}

--demand_point_table_path {demand_point_table_path}
--population_year {population_year}
--population_growth_as_percent_of_population_per_year {population_growth_as_percent_of_population_per_year}

financing_year = 2016
time_horizon_in_years = 10
discount_rate_as_percent_of_cash_flow_per_year = 10

demand_point_table_path = datasets/leona-selected-demand-points.csv
population_year = 2016
Expand Down
16 changes: 2 additions & 14 deletions estimate_electricity_cost_by_technology_from_population.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from invisibleroads_macros.configuration import TerseArgumentParser
from invisibleroads_macros.disk import make_folder

from infrastructure_planning.macros import load_and_run
from infrastructure_planning.macros import BasicArgumentParser, load_and_run
from infrastructure_planning.preprocessors import (
normalize_demand_point_table,
normalize_connection_type_table,
Expand Down Expand Up @@ -37,19 +35,9 @@


if __name__ == '__main__':
x = TerseArgumentParser()
x = BasicArgumentParser()
add_arguments_for_estimate_population(x)

x.add_argument(
'configuration_path',
metavar='CONFIGURATION_PATH', nargs='?')
x.add_argument(
'-w', '--source_folder',
metavar='FOLDER')
x.add_argument(
'-o', '--target_folder',
metavar='FOLDER', type=make_folder)

x.add_argument(
'--selected_technologies_text_path',
metavar='PATH')
Expand Down
6 changes: 2 additions & 4 deletions estimate_grid_mv_line_budget_in_meters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from invisibleroads_macros.configuration import TerseArgumentParser

from infrastructure_planning.macros import load_and_run
from infrastructure_planning.macros import BasicArgumentParser, load_and_run
from infrastructure_planning.preprocessors import (
normalize_demand_point_table)

Expand All @@ -16,7 +14,7 @@ def add_arguments_for_estimate_population(x):


if __name__ == '__main__':
x = TerseArgumentParser()
x = BasicArgumentParser()
add_arguments_for_estimate_population(x)
load_and_run([
normalize_demand_point_table,
Expand Down
14 changes: 11 additions & 3 deletions infrastructure_planning/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import simplejson as json
import shutil
from invisibleroads_macros.configuration import TerseArgumentParser
from invisibleroads_macros.disk import make_enumerated_folder_for, make_folder
from invisibleroads_macros.geometry import flip_geometry_coordinates
from invisibleroads_macros.iterable import merge_dictionaries
Expand All @@ -18,6 +19,16 @@
from .parsers import load_files


class BasicArgumentParser(TerseArgumentParser):

def __init__(self, *args, **kw):
super(BasicArgumentParser, self).__init__(*args, **kw)
self.add_argument(
'configuration_path', metavar='CONFIGURATION_PATH', nargs='?')
self.add_argument('-w', '--source_folder', metavar='FOLDER')
self.add_argument('-o', '--target_folder', metavar='FOLDER')


class InfrastructureGraph(Graph):

def cycle_nodes(self):
Expand Down Expand Up @@ -226,9 +237,6 @@ def rename_keys(value_by_key, prefix='', suffix=''):

def _get_argument_file_name(k, v):
file_base = k
file_base = file_base.replace('_geotable_path', 's')
file_base = file_base.replace('_table_path', 's')
file_base = file_base.replace('_text_path', '')
file_base = file_base.replace('_path', '')
file_extension = splitext(v)[1]
return file_base.replace('_', '-') + file_extension
6 changes: 6 additions & 0 deletions missions/ProductionCountdown-20160711.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ For some reason, I'm getting an error.

Ok, it works now.

20161024-1400 - 20161024-1430: 30 minutes

Add BasicArgumentParser
Check that everything still works
Check tests

# Tasks

Generate points.csv
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
install_requires=[
'python-dateutil',
'geopy',
'invisibleroads-macros>=0.7.2',
'invisibleroads-macros>=0.7.3',
'simplejson',
],
tests_require=[
Expand Down

0 comments on commit cff8463

Please sign in to comment.