Debian Codegraph @

clevercsv/console/application.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 """
4 CleverCSV Command line application.
5
6 """
7
8 from wilderness import Application
9
10 from .. import __version__
11 from .commands import CodeCommand
12 from .commands import DetectCommand
13 from .commands import ExploreCommand
14 from .commands import StandardizeCommand
15 from .commands import ViewCommand
16
17
18 class CleverCSVApplication(Application):
19 _description = (
20 "CleverCSV is a Python library and command line tool for dealing "
21 "with messy CSV files. It consists of a number of commands that can "
22 "be used to analyze, explore, or standardize a messy CSV file.\n\n"
23 "Further help and documentation can be found online at "
24 "https://github.com/alan-turing-institute/CleverCSV or "
25 "https://clevercsv.readthedocs.io"
26 )
27 _extra = {
28 "Commands": (
29 "The following commands are available in CleverCSV:\n\n"
30 "clevercsv-code(1)\n"
31 "\tGenerate Python code to import a given CSV file\n\n"
32 "clevercsv-detect(1)\n"
33 "\tDetect the dialect of a CSV file\n\n"
34 "clevercsv-explore(1)\n"
35 "\tInfer the dialect and open the file in an interactive Python "
36 "session\n\n"
37 "clevercsv-standardize(1)\n"
38 "\tConvert a messy CSV file to one that follows RFC-4180\n\n"
39 "clevercsv-view(1)\n"
40 "\tDetect the dialect and open the CSV file using TabView"
41 ),
42 "Authors": (
43 "The CleverCSV package was originally written by Gerrit van den "
44 "Burg and came out of scientific research on wrangling messy CSV "
45 "files by Gerrit van den Burg, Alfredo Nazabal, and Charles "
46 "Sutton. This research was conducted at and supported by The "
47 "Alan Turing Institute. CleverCSV has since benefitted from a "
48 "number of open-source contributors on GitHub."
49 ),
50 "Reporting Bugs": (
51 "If you encounter an issue in CleverCSV, please open an issue "
52 "or submit a pull request at "
53 "https://github.com/alan-turing-institute/CleverCSV. Please don't "
54 "hesitate, you're helping to make this project better for "
55 "everyone!"
56 ),
57 "Notes": (
58 "1. CleverCSV GitHub repository\n"
59 " https://github.com/alan-turing-institute/CleverCSV\n\n"
60 "2. CleverCSV documentation\n"
61 " https://clevercsv.readthedocs.io\n\n"
62 "3. Wrangling Messy CSV Files by Detecting Row and Type Patterns\n"
63 " https://gertjanvandenburg.com/papers/VandenBurg_Nazabal_Sutton_-_Wrangling_Messy_CSV_Files_by_Detecting_Row_and_Type_Patterns_2019.pdf"
64 ),
65 }
66
67 def __init__(self) -> None:
68 super().__init__(
69 "clevercsv",
70 version=__version__,
71 title="CleverCSV command line tool",
72 author="G.J.J. van den Burg",
73 description=self._description,
74 extra_sections=self._extra,
75 )
76
77 def register(self) -> None:
78 self.add_argument(
79 "-V",
80 "--version",
81 help="Show version and exit",
82 action="version",
83 version=__version__,
84 )
85 self.add_argument(
86 "-v", "--verbose", help="Enable verbose mode", action="store_true"
87 )
88
89
90 def build_application() -> Application:
91 app = CleverCSVApplication()
92 app.add(DetectCommand())
93 app.add(ViewCommand())
94 app.add(StandardizeCommand())
95 app.add(CodeCommand())
96 app.add(ExploreCommand())
97 return app