def main(): offset = 1 conf=None # Check for help... if len(sys.argv) == 1 or sys.argv[1] in ["help"]: sentry_help() sys.exit() cmd = sys.argv[0] sys.argv = sys.argv[1:] if sys.argv[0] in ["init"]: if len(sys.argv) < 2: print("Missing filename argument") sentry_help() sys.exit() initialize(conf=sys.argv[1]) sys.exit() if sys.argv[0] in ["example"]: if len(sys.argv) < 2: print("Missing filename argument") sentry_help() sys.exit() example(path=sys.argv[1]) if sys.argv[0] in ["run", "commit"]: runcmd = sys.argv[0] if len(sys.argv) < 2: print("Missing arguments") sentry_help() sys.exit() # Handle the configuration option... sys.argv = sys.argv[1:] print("Before config", sys.argv) if sys.argv[0] in ["-c", "--conf"]: if len(sys.argv) < 3: print("Missing configuration file") sentry_help() sys.exit() conf = sys.argv[1] config = load_configuration(conf) sys.argv = sys.argv[2:] else: config = {} if 'spec' not in config: config['spec'] = {} config['spec']['run'] = runcmd if sys.argv[0] in ["-m", "--message"]: if len(sys.argv) < 3: print("Missing configuration file") sentry_help() sys.exit() message = sys.argv[1] config['spec']['message'] = message sys.argv = sys.argv[2:] print("Found config", config) pydatasentry.initialize(config) # Now load the program... sys.argv.insert(0, cmd) load_program()
#!/usr/bin/env python #!/usr/bin/env python import statsmodels.formula.api as smf import statsmodels.api as sm import numpy as np import pandas import pydatasentry if __name__ == "__main__": pydatasentry.initialize() df = sm.datasets.get_rdataset("Guerry", "HistData").data df = df[['Lottery', 'Literacy', 'Wealth', 'Region']].dropna() df.head() mod = smf.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df) res = mod.fit() print(res.summary())