From 6d479d8c0764b7b77cbfd082a7b09cbfae6fa8b2 Mon Sep 17 00:00:00 2001
From: Kian <105409698+knejadshamsi@users.noreply.github.com>
Date: Sun, 15 Sep 2024 20:24:29 -0400
Subject: [PATCH] help about section added
---
styles/help.py | 289 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 273 insertions(+), 16 deletions(-)
diff --git a/styles/help.py b/styles/help.py
index a1e4af9..08db1b3 100644
--- a/styles/help.py
+++ b/styles/help.py
@@ -4,30 +4,283 @@ from rich.console import Console
from rich.console import Group
from rich.padding import Padding
from rich.panel import Panel
+from rich.syntax import Syntax
+
def population_help():
- line1 = "This CLI tool processes [yellow bold]MATSim population XML files[/yellow bold] and prepares the data for storage in either [green bold].csv[/green bold] file or in [blue bold]PostgreSQL[/blue bold] database with [blue bold]PostGIS[/blue bold] integration."
- line2 = "It extracts key data such as coordinates, converting them into a format ready for geospatial.\nUse the available [underline bold]options[/underline bold] to modify the behavior, such as [underline bold]cleaning[/underline bold] the data with missing values, or choosing to either [underline bold]replace[/underline bold] or [underline bold]append[/underline bold] data in the target table."
- line3 = "The resulting table structure includes columns such as the following:"
- line4 = "[red bold]NOTE:[/red bold] Ensure PostgreSQL connection details are provided via a [underline bold bright_cyan].env[/underline bold bright_cyan] file.\n[red bold]NOTE:[/red bold] By default if a [underline].log[/underline] exist with the same name in the same directory of file, It will use that to prcoess the file"
- table = Table("id","lon","lat","geom","time","age","sex","person_id","economic_sector","household_id","household_income")
- table.add_row("1","45.89977111012078","-73.26605847316777","0101000020E61000005CED21B32BF3464013451E1A075152C0","07:00:00","4","1","1","0","1","4")
- table.add_row("2","45.89977111012078","-73.26605847316777","0101000020E61000005CED21B32BF3464013451E1A075152C0","08:00:00","4","2","2","0","1","4")
- lines = f"{line1} \n{line2} \n{line3}"
- panel = Padding(Panel(Padding(Group(lines,Padding(table, (1,0)),line4), (1,1)), title="About",title_align="left"), (1,0,0,0))
+ line1 = (
+ "This CLI tool processes [yellow bold]MATSim population XML files[/yellow bold] and prepares "
+ "the data for storage in either [green bold].csv[/green bold] files or a [blue bold]PostgreSQL[/blue bold] "
+ "database with [blue bold]PostGIS[/blue bold] integration."
+ )
+ line2 = (
+ "It extracts key data such as coordinates, converting them into a format ready for geospatial analysis.\n"
+ "Use the available [underline bold]options[/underline bold] to modify the behavior, such as "
+ "[underline bold]cleaning[/underline bold] the data by removing rows with missing values, or choosing to "
+ "either [underline bold]replace[/underline bold] or [underline bold]append[/underline bold] data in the target table."
+ )
+ line3 = "The expected format of the input MATSim population XML file is as follows:"
+
+ code = '''
+
+
+
+ 30
+
+
+
+
+
+
+
+
+
+
+'''
+ syntax = Padding(Syntax(code, "xml", theme="native", line_numbers=True),(1,0))
+
+ line4 = "[red bold]NOTE:[/red bold] Make sure the dividers (line [bold]2[/bold] and [bold]14[/bold]) are present in the file; One divider before the first person and one divider after every person there after.\n\nThe resulting table structure includes columns such as the following:"
+ line5 = (
+ "[red bold]NOTE:[/red bold] Ensure PostgreSQL connection details are provided via a "
+ "[underline bold bright_cyan].env[/underline bold bright_cyan] file.\n"
+ "[red bold]NOTE:[/red bold] By default, if a [underline].log[/underline] file exists with the same name "
+ "in the same directory as the input file, it will use that to process the file."
+ )
+
+ table = Table(
+ "id", "lon", "lat", "geom", "time", "age", "sex", "person_id", "economic_sector", "household_id", "household_income"
+ )
+ table.add_row(
+ "1",
+ "45.89977111012078",
+ "-73.26605847316777",
+ "0101000020E61000005CED21B32BF3464013451E1A075152C0",
+ "07:00:00",
+ "30",
+ "1",
+ "1",
+ "0",
+ "1",
+ "4",
+ )
+
+ lines = f"{line1}\n{line2}\n\n{line3}"
+ group_content = Group(lines, syntax, line4, Padding(table, (1, 0)), line5)
+ panel = Padding(Panel(Padding(group_content, (1, 1)), title="About", title_align="left"),(1,0,0,0))
return panel
+
def network_help():
- test = Padding("Hello network", (1,1))
- return Panel(test, title="About",title_align="left")
+ line1 = (
+ "This CLI tool processes [yellow bold]MATSim network XML files[/yellow bold] and prepares "
+ "the data for storage in either [green bold].csv[/green bold] files or a [blue bold]PostgreSQL[/blue bold] "
+ "database with [blue bold]PostGIS[/blue bold] integration."
+ )
+ line2 = (
+ "It extracts key data such as nodes and links, converting them into a format ready for geospatial analysis.\n"
+ "Use the available [underline bold]options[/underline bold] to modify the behavior, such as "
+ "[underline bold]cleaning[/underline bold] the data by removing rows with missing values, or choosing to "
+ "either [underline bold]replace[/underline bold] or [underline bold]append[/underline bold] data in the target table."
+ )
+ line3 = "The expected format of the input MATSim network XML file is as follows:"
+
+ # Code snippet with syntax highlighting
+ code = '''
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'''
+ syntax = Padding(Syntax(code, "xml", theme="native", line_numbers=True), (1, 0))
+
+ line4 = (
+ "[red bold]NOTE:[/red bold] Make sure the dividers (lines [bold]3[/bold], [bold]9[/bold], and [bold]15[/bold]) are present in the file; "
+ "One divider before the nodes section and one divider after the nodes and links sections.\n\n"
+ "The resulting table structures include columns such as the following:"
+ )
+ line5 = (
+ "[red bold]NOTE:[/red bold] Ensure PostgreSQL connection details are provided via a "
+ "[underline bold bright_cyan].env[/underline bold bright_cyan] file.\n"
+ "[red bold]NOTE:[/red bold] By default, if a [underline].log[/underline] file exists with the same name "
+ "in the same directory as the input file, it will use that to process the file."
+ )
+
+ # Table for 'links'
+ table_links = Table(
+ "id", "from", "to", "length", "freespeed", "capacity", "permlanes", "oneway", "modes"
+ )
+ table_links.add_row(
+ "1",
+ "1761723297",
+ "4407523214",
+ "506.2083628326979",
+ "13.88888888888889",
+ "600.0",
+ "1.0",
+ "1",
+ "car,car_passenger",
+ )
+ table_links.add_row(
+ "10",
+ "6545227882",
+ "300061322",
+ "567.0835225729793",
+ "19.444444444444443",
+ "1000.0",
+ "1.0",
+ "1",
+ "car,car_passenger",
+ )
+
+ # Table for 'links_attr'
+ table_links_attr = Table(
+ "id", "osm_way_highway", "osm_way_id", "osm_way_lanes", "osm_way_name", "sidewalk", "osm_way_oneway"
+ )
+ table_links_attr.add_row(
+ "1",
+ "unclassified",
+ "164553215",
+ "2",
+ "Montée Cadot",
+ "0.0",
+ "yes",
+ )
+
+ lines = f"{line1}\n{line2}\n\n{line3}"
+ group_content = Group(
+ lines,
+ syntax,
+ line4,
+ "[bold]\nlinks:[/bold]",
+ Padding(table_links, (1, 0)),
+ "[bold]links_attr:[/bold]",
+ Padding(table_links_attr, (1, 0)),
+ line5,
+ )
+ panel = Padding(Panel(Padding(group_content, (1, 1)), title="About", title_align="left"), (1, 0, 0, 0))
+ return panel
def metro_help():
- test = Padding("Hello network", (1,1))
- return Panel(test, title="About",title_align="left")
+ line1 = (
+ "This CLI tool processes [yellow bold]metro station and line shapefiles[/yellow bold] "
+ "for a specified city and prepares the data for storage in either [green bold].csv[/green bold] "
+ "files or a [blue bold]PostgreSQL[/blue bold] database with [blue bold]PostGIS[/blue bold] integration."
+ )
+ line2 = (
+ "It extracts key data such as station locations and metro lines, converting them into a format "
+ "ready for geospatial analysis.\n"
+ "Use the available [underline bold]options[/underline bold] to modify the behavior, such as "
+ "[underline bold]cleaning[/underline bold] the data by removing rows with missing values, or choosing to "
+ "either [underline bold]replace[/underline bold] or [underline bold]append[/underline bold] data in the target table."
+ )
+ line3 = (
+ "For [bold]Montréal[/bold], To obtain the required shapefiles, please visit the following link:\n"
+ "[bright_cyan bold link=https://www.stm.info/en/about/developers?utm_campaign=menubas&utm_source=developpeurs]"
+ "https://www.stm.info/en/about/developers[/bright_cyan bold link]\n"
+ "Scroll down and find [bold]\"Download the Shapefile\"[/bold] button and download it.\n"
+ "Extract the downloaded archive to obtain the two [bold].shp[/bold] files."
+ )
+ line4 = "The resulting table structures include columns such as the following:\n"
+
+ # Example table for 'metro-stations'
+ table_stations = Table(
+ "route_id", "route_name", "headsign", "shape_id", "ct", "service_id", "geometry"
+ )
+ table_stations.add_row(
+ "1", "Ligne 1 - Verte", "Station Angrignon", "11072", "0", "24S", "LINESTRING (302040.087 5050741.446, 301735.98 ...)"
+ )
+
+ # Example table for 'metro-lines'
+ table_lines = Table(
+ "id", "name", "geom", "stop_url", "wheelchair", "route_id", "loc_type", "shelter", "service_id"
+ )
+ table_lines.add_row(
+ "10118", "43", "Station Angrignon", "http://www.stm.info/fr/infos/reseaux/metro/ang...", "1", "1", "0", "NaN", "24S"
+ )
+
+ line5 = (
+ "[red bold]NOTE:[/red bold] Ensure PostgreSQL connection details are provided via a "
+ "[underline bold bright_cyan].env[/underline bold bright_cyan] file.\n"
+
+ )
+
+ lines = f"{line1}\n{line2}\n\n{line3}\n\n{line4}"
+ group_content = Group(
+ lines,
+ "\n[bold]metro-stations:[/bold]",
+ Padding(table_stations, (1, 0)),
+ "[bold]metro-lines:[/bold]",
+ Padding(table_lines, (1, 0)),
+ line5,
+ )
+ panel = Padding(Panel(Padding(group_content, (1, 1)), title="About", title_align="left"), (1, 0, 0, 0))
+ return panel
def bus_help():
- test = Padding("Hello network", (1,1))
- return Panel(test, title="About",title_align="left")
+ line1 = (
+ "This CLI tool processes [yellow bold]bus station and line shapefiles[/yellow bold] "
+ "for a specified city and prepares the data for storage in either [green bold].csv[/green bold] "
+ "files or a [blue bold]PostgreSQL[/blue bold] database with [blue bold]PostGIS[/blue bold] integration."
+ )
+ line2 = (
+ "It extracts key data such as station locations and bus lines, converting them into a format "
+ "ready for geospatial analysis.\n"
+ "Use the available [underline bold]options[/underline bold] to modify the behavior, such as "
+ "[underline bold]cleaning[/underline bold] the data by removing rows with missing values, or choosing to "
+ "either [underline bold]replace[/underline bold] or [underline bold]append[/underline bold] data in the target table."
+ )
+ line3 = (
+ "For [bold]Montréal[/bold], To obtain the required shapefiles, please visit the following link:\n"
+ "[bright_cyan bold link=https://www.stm.info/en/about/developers?utm_campaign=menubas&utm_source=developpeurs]"
+ "https://www.stm.info/en/about/developers[/bright_cyan bold link]\n"
+ "Scroll down and find [bold]\"Download the Shapefile\"[/bold] button and download it.\n"
+ "Extract the downloaded archive to obtain the two [bold].shp[/bold] files."
+ )
+ line4 = "The resulting table structures include columns such as the following:\n"
+
+ # Example table for 'bus-stations'
+ table_stations = Table(
+ "stop_code","stop_id","stop_name","stop_url","wheelchair","route_id","loc_type","shelter","service_id","geometry"
+ )
+ table_stations.add_row(
+ "10282","66-01","Station Cartier - Terminus Cartier (A)","","1","","2","","24S","POINT (290599.75509576086 5046736.8438161155)"
+ )
+
+ # Example table for 'bus-lines'
+ table_lines = Table(
+ "route_id","route_name","headsign","shape_id","ct","service_id","geometry"
+ )
+ table_lines.add_row(
+ "767","La Ronde / Station Jean-Drapeau","Est","7670032","59","24S","LINESTRING (302272.2175821533 5041335.954894771, 302272.06122515834..."
+ )
+
+ line5 = (
+ "[red bold]NOTE:[/red bold] Ensure PostgreSQL connection details are provided via a "
+ "[underline bold bright_cyan].env[/underline bold bright_cyan] file.\n"
+ )
+
+ lines = f"{line1}\n{line2}\n\n{line3}\n\n{line4}"
+ group_content = Group(
+ lines,
+ "\n[bold]bus-stations:[/bold]",
+ Padding(table_stations, (1, 0)),
+ "[bold]bus-lines:[/bold]",
+ Padding(table_lines, (1, 0)),
+ line5,
+ )
+ panel = Padding(Panel(Padding(group_content, (1, 1)), title="About", title_align="left"), (1, 0, 0, 0))
+ return panel
def print_help():
console = Console()
@@ -35,4 +288,8 @@ def print_help():
if (sys.argv[1] == "population"):
console.print(population_help())
elif (sys.argv[1] == "network"):
- console.print(network_help())
\ No newline at end of file
+ console.print(network_help())
+ elif (sys.argv[1] == "metro"):
+ console.print(metro_help())
+ elif (sys.argv[1] == "bus"):
+ console.print(bus_help())
\ No newline at end of file