Projects STRLCPY cupp Commits 0905db74
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    cupp.py
    skipped 47 lines
    48 48  CONFIG = {}
    49 49   
    50 50   
    51  -def read_config(filename="cupp.cfg"):
     51 +def read_config(filename):
    52 52   """Read the given configuration file and update global variables to reflect
    53 53   changes (CONFIG)."""
    54 54   
    55  - # global CONFIG
     55 + if os.path.isfile(filename):
    56 56   
    57  - # Reading configuration file
    58  - config = configparser.ConfigParser()
    59  - config.read(filename)
     57 + # global CONFIG
    60 58   
    61  - CONFIG["global"] = {
    62  - "years": config.get("years", "years").split(","),
    63  - "chars": config.get("specialchars", "chars").split(","),
    64  - "numfrom": config.getint("nums", "from"),
    65  - "numto": config.getint("nums", "to"),
    66  - "wcfrom": config.getint("nums", "wcfrom"),
    67  - "wcto": config.getint("nums", "wcto"),
    68  - "threshold": config.getint("nums", "threshold"),
    69  - "alectourl": config.get("alecto", "alectourl"),
    70  - "dicturl": config.get("downloader", "dicturl"),
    71  - }
     59 + # Reading configuration file
     60 + config = configparser.ConfigParser()
     61 + config.read(filename)
    72 62   
    73  - # 1337 mode configs, well you can add more lines if you add it to the
    74  - # config file too.
    75  - leet = functools.partial(config.get, "leet")
    76  - leetc = {}
    77  - letters = {"a", "i", "e", "t", "o", "s", "g", "z"}
     63 + CONFIG["global"] = {
     64 + "years": config.get("years", "years").split(","),
     65 + "chars": config.get("specialchars", "chars").split(","),
     66 + "numfrom": config.getint("nums", "from"),
     67 + "numto": config.getint("nums", "to"),
     68 + "wcfrom": config.getint("nums", "wcfrom"),
     69 + "wcto": config.getint("nums", "wcto"),
     70 + "threshold": config.getint("nums", "threshold"),
     71 + "alectourl": config.get("alecto", "alectourl"),
     72 + "dicturl": config.get("downloader", "dicturl"),
     73 + }
     74 + 
     75 + # 1337 mode configs, well you can add more lines if you add it to the
     76 + # config file too.
     77 + leet = functools.partial(config.get, "leet")
     78 + leetc = {}
     79 + letters = {"a", "i", "e", "t", "o", "s", "g", "z"}
    78 80   
    79  - for letter in letters:
    80  - leetc[letter] = config.get("leet", letter)
     81 + for letter in letters:
     82 + leetc[letter] = config.get("leet", letter)
     83 + 
     84 + CONFIG["LEET"] = leetc
    81 85   
    82  - CONFIG["LEET"] = leetc
     86 + return True
     87 + 
     88 + else:
     89 + print("Configuration file " + filename + " not found!")
     90 + sys.exit("Exiting.")
     91 + 
     92 + return False
    83 93   
    84 94   
    85 95  def make_leet(x):
    skipped 912 lines
    998 1008  def main():
    999 1009   """Command-line interface to the cupp utility"""
    1000 1010   
    1001  - read_config()
     1011 + read_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), "cupp.cfg"))
    1002 1012   
    1003 1013   parser = get_parser()
    1004 1014   args = parser.parse_args()
    skipped 65 lines
Please wait...
Page is in error, reload to recover