def gamer_create(): codename, code = request.json['codename'], request.json['code'] # codename, code = request.query['codename'], request.query['code'] project, *moduler = codename.split('/') filename = "/".join(moduler) code = dcd(str.encode(code)).decode("utf-8") try: code_status = DS.create_file(project, filename, code) except Exception as err: code_status = "Fail creating {}: {}".format(filename, err) return code_status
def _gamer_claim(projecter, moduler=""): form_values = "author_nick author_name author_email author_org author_site author_public".split() code = {key: request.params[key] for key in form_values} key = str(uuid.uuid4())[:8] spy = str({key: code}).replace("'", '"')[1:-1] + ",[\n" # coded = str(code).replace("'", '"') author_index = projecter if moduler else '_spy' filename = "{}/__score__.py".format(moduler) if moduler else "__score__.py" code_status = '' try: print("_gamer_claimtry", author_index, projecter, filename, spy) code_status = DS.append_file(author_index, filename, "],\n"+spy) except Exception as err: print("_gamer_claimexcept", code_status, err) if "404" in str(err): try: print("_gamer_claimif 404 ", author_index, projecter, filename, spy) code_status += DS.create_file(author_index, filename, "{\n"+spy) except Exception as err: code_status = "Fail creating {}: {}, {}".format(filename, str(err), code_status) print("Play _gamer_claim Exception", code_status, err) return code_status
def _gamer_claim(projecter, moduler=""): modl, namel = projecter if moduler else '_spy', "__author__.py" form_values = "author_nick author_name author_email author_org author_site author_public".split( ) code = {key: request.params[key] for key in form_values} key = moduler if moduler else projecter spy = str({key: code}).replace("'", '"')[1:-1] + ",\n" # coded = str(code).replace("'", '"') author_index = projecter if moduler else '_spy' action = "/supygirls/gamer/{}/".format(projecter) claim = "{}/".format(projecter) if moduler else "" filename = "{}/__author__.py".format( moduler) if moduler else "__author__.py" try: print(author_index, projecter, filename, spy) code_status = DS.append_file(author_index, filename, spy) filename = '{}/__author__.py'.format( moduler) if moduler else '__author__.py' code_status += DS.create_file(projecter, filename, "{\n" + spy) print(code, filename) code_file = DS.get_file_contents(modl, '', namel) code = "{" + dcd(str.encode( code_file.content)).decode("utf-8")[1:-2] + "}" code = json.loads(code) cenas = [(girl, code[girl.lower()]['author_nick'] if girl.lower() in code else 'livre') for girl in GIRLS] except Exception as err: code_status = "Fail creating {}: {}".format(filename, err) cenas = [(girl, 'livre') for girl in GIRLS] return dict(pagetitle="SuPyGirls - {}".format(projecter), title=projecter, action=action, claim=claim, image="garden.jpg", cenas=cenas, status=code_status)