diff --git a/parse.js b/parse.js index 8387b24..027356f 100755 --- a/parse.js +++ b/parse.js @@ -30,13 +30,29 @@ const TOC = '}\n' + '\n'; +const LRU_CACHE = + 'from functools import lru_cache\n' + + '\n' + + ' \n' + + 'def fib(n):\n' + + ' return n if n < 2 else fib(n-2) + fib(n-1)\n'; + +const DATACLASS = + 'from dataclasses import make_dataclass\n' + + '<class> = make_dataclass(\'<class_name>\', <coll_of_attribute_names>)\n' + + '<class> = make_dataclass(\'<class_name>\', <coll_of_tuples>)\n' + + '<tuple> = (\'<attr_name>\', <type> [, <default_value>])'; + +const SHUTIL_COPY = + 'shutil.copy(from, to) # Copies the file. \'to\' can exist or be a dir.\n' + + 'shutil.copytree(from, to) # Copies the directory. \'to\' must not exist.\n'; + const OS_RENAME = 'os.rename(from, to) # Renames/moves the file or directory.\n' + 'os.replace(from, to) # Same, but overwrites \'to\' if it exists.\n'; -const SHUTIL_COPY = - 'shutil.copy(from, to) # Copies the file. \'to\' can exist or be a dir.\n' + - 'shutil.copytree(from, to) # Copies the directory. \'to\' must not exist.\n'; +const TYPE = + '<class> = type(\'<class_name>\', <parents_tuple>, <attributes_dict>)'; const EVAL = 'from ast import literal_eval\n' + @@ -47,21 +63,12 @@ const EVAL = ' literal_eval(\'abs(1)\')\n' + 'ValueError: malformed node or string\n'; -const LRU_CACHE = - 'from functools import lru_cache\n' + - '\n' + - ' \n' + - 'def fib(n):\n' + - ' return n if n < 2 else fib(n-2) + fib(n-1)\n'; - -const TYPE = - '<class> = type(\'<class_name>\', <parents_tuple>, <attributes_dict>)'; - -const DATACLASS = - 'from dataclasses import make_dataclass\n' + - '<class> = make_dataclass(\'<class_name>\', <coll_of_attribute_names>)\n' + - '<class> = make_dataclass(\'<class_name>\', <coll_of_tuples>)\n' + - '<tuple> = (\'<attr_name>\', <type> [, <default_value>])'; +const PROGRESS_BAR = + '# $ pip3 install tqdm\n' + + 'from tqdm import tqdm\n' + + 'for el in tqdm([1, 2, 3], desc=\'Processing\'):\n' + + ' pass\n' + + 'Processing: 100%|██████████████████| 3/3 [00:00<00:00, 11516.49it/s]\n'; const PYINSTALLER = '$ pip3 install pyinstaller\n' + @@ -75,13 +82,6 @@ const INDEX = '
\'#<title>\'
will limit the search to the titles.