signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def parse_url(self): | url = urlparse(self.url).path<EOL>url = url.split('<STR_LIT>')[<NUM_LIT:0>]<EOL>if '<STR_LIT::>' in url:<EOL><INDENT>url = url.split('<STR_LIT::>')[<NUM_LIT:1>]<EOL><DEDENT>try:<EOL><INDENT>project, repo = url.split('<STR_LIT:/>')[-<NUM_LIT:2>:]<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ParserError('<STR_LIT>'.f... | Parse a git/ssh/http(s) url. | f15618:c1:m1 |
def __getattr__(self, name): | return self.data[name].format(**self.data)<EOL> | Return formatted string from :attr:`format`. | f15620:c1:m1 |
@property<EOL><INDENT>def app(self):<DEDENT> | logging.warning('<STR_LIT>')<EOL>return self.app_name()<EOL> | Return the generated app name. | f15620:c1:m2 |
@property<EOL><INDENT>def project(self):<DEDENT> | return self.data['<STR_LIT>']<EOL> | Return the project property. | f15620:c1:m3 |
@property<EOL><INDENT>def repo(self):<DEDENT> | return self.data['<STR_LIT>']<EOL> | Return the repo property. | f15620:c1:m4 |
@property<EOL><INDENT>def env(self):<DEDENT> | return self.data['<STR_LIT>']<EOL> | Return the env property. | f15620:c1:m5 |
def app_name(self): | app = self.format['<STR_LIT>'].format(**self.data)<EOL>return app<EOL> | Generate application name. | f15620:c1:m6 |
def dns_elb(self): | dns = self.format['<STR_LIT>'].format(**self.data)<EOL>return dns<EOL> | Generate elb dns domain. | f15620:c1:m7 |
def dns_elb_region(self): | dns = self.format['<STR_LIT>'].format(**self.data)<EOL>return dns<EOL> | Generate dns domain with region. | f15620:c1:m8 |
def dns_global(self): | dns = self.format['<STR_LIT>'].format(**self.data)<EOL>return dns<EOL> | Generate dns global domain with no region. | f15620:c1:m9 |
def dns_region(self): | dns = self.format['<STR_LIT>'].format(**self.data)<EOL>return dns<EOL> | Generate region specific DNS. | f15620:c1:m10 |
def dns_instance(self): | instance = self.format['<STR_LIT>'].format(**self.data)<EOL>return instance<EOL> | Generate dns instance. | f15620:c1:m11 |
def dns(self): | dns = {<EOL>'<STR_LIT>': self.dns_elb(),<EOL>'<STR_LIT>': self.dns_elb_region(),<EOL>'<STR_LIT>': self.dns_global(),<EOL>'<STR_LIT>': self.dns_region(),<EOL>'<STR_LIT>': self.dns_instance(),<EOL>}<EOL>return dns<EOL> | DNS details. | f15620:c1:m12 |
def s3_app_bucket(self, include_region=False): | if include_region:<EOL><INDENT>s3_app_bucket = self.format['<STR_LIT>'].format(**self.data)<EOL><DEDENT>else:<EOL><INDENT>s3_app_bucket = self.format['<STR_LIT>'].format(**self.data)<EOL><DEDENT>return s3_app_bucket<EOL> | Generate s3 application bucket name.
Args:
include_region (bool): Include region in the name generation. | f15620:c1:m13 |
def shared_s3_app_bucket(self, include_region=False): | if include_region:<EOL><INDENT>shared_s3_app_bucket = self.format['<STR_LIT>'].format(**self.data)<EOL><DEDENT>else:<EOL><INDENT>shared_s3_app_bucket = self.format['<STR_LIT>'].format(**self.data)<EOL><DEDENT>return shared_s3_app_bucket<EOL> | Generate shared s3 application bucket name.
Args:
include_region (bool): Include region in the name generation. | f15620:c1:m14 |
def iam(self): | iam = {<EOL>'<STR_LIT>': self.format['<STR_LIT>'].format(**self.data),<EOL>'<STR_LIT>': self.format['<STR_LIT>'].format(**self.data),<EOL>'<STR_LIT>': self.format['<STR_LIT>'].format(**self.data),<EOL>'<STR_LIT>': self.format['<STR_LIT>'].format(**self.data),<EOL>'<STR_LIT>': self.format['<STR_LIT>'].format(**self.data... | Generate iam details. | f15620:c1:m15 |
def archaius(self): | bucket = self.format['<STR_LIT>'].format(**self.data)<EOL>path = self.format['<STR_LIT>'].format(**self.data)<EOL>archaius_name = self.format['<STR_LIT>'].format(**self.data)<EOL>archaius = {'<STR_LIT>': archaius_name, '<STR_LIT>': bucket, '<STR_LIT:path>': path}<EOL>return archaius<EOL> | Generate archaius bucket path. | f15620:c1:m16 |
def jenkins(self): | job_name = self.format['<STR_LIT>'].format(**self.data)<EOL>job = {'<STR_LIT:name>': job_name}<EOL>return job<EOL> | Generate jenkins job details. | f15620:c1:m17 |
def gitlab(self): | main_name = self.format['<STR_LIT>'].format(**self.data)<EOL>qe_name = self.format['<STR_LIT>'].format(**self.data)<EOL>config_name = self.format['<STR_LIT>'].format(**self.data)<EOL>git = {<EOL>'<STR_LIT>': config_name,<EOL>'<STR_LIT>': main_name,<EOL>'<STR_LIT>': qe_name,<EOL>}<EOL>return git<EOL> | Generate gitlab details. | f15620:c1:m18 |
def apigateway(self): | domain = self.format['<STR_LIT>'].format(**self.data)<EOL>return {<EOL>'<STR_LIT>': domain,<EOL>}<EOL> | Generate apigateway details. | f15620:c1:m19 |
def get_formats(self): | return self.config<EOL> | Return overlaid configurations. | f15621:c0:m1 |
def __init__(self, request: Request): | self.request = request<EOL> | Inject Any Dependencies From The Service Container.
Arguments:
Request {masonite.request.Request} -- The Masonite request object | f15643:c0:m0 |
def before(self): | if not self.request.user():<EOL><INDENT>self.request.redirect_to('<STR_LIT>')<EOL><DEDENT> | Run This Middleware Before The Route Executes. | f15643:c0:m1 |
def after(self): | pass<EOL> | Run This Middleware After The Route Executes. | f15643:c0:m2 |
def __init__(self, request: Request): | self.request = request<EOL> | Inject Any Dependencies From The Service Container.
Arguments:
Request {masonite.request.Request} -- The Masonite request object. | f15644:c0:m0 |
def before(self): | self.load_user()<EOL>return self.request<EOL> | Run This Middleware Before The Route Executes. | f15644:c0:m1 |
def after(self): | pass<EOL> | Run This Middleware After The Route Executes. | f15644:c0:m2 |
def load_user(self): | self.request.set_user(Auth(self.request).user())<EOL> | Load user into the request.
Arguments:
request {masonite.request.Request} -- The Masonite request object. | f15644:c0:m3 |
def __init__(self, request: Request): | self.request = request<EOL> | Inject Any Dependencies From The Service Container.
Arguments:
Request {masonite.request.Request} -- The Masonite request object | f15645:c0:m0 |
def before(self): | user = self.request.user()<EOL>if user and user.verified_at is None:<EOL><INDENT>self.request.redirect('<STR_LIT>')<EOL><DEDENT> | Run This Middleware Before The Route Executes. | f15645:c0:m1 |
def after(self): | pass<EOL> | Run This Middleware After The Route Executes. | f15645:c0:m2 |
def show(self, view: View, request: Request): | return view.render('<STR_LIT>', {<EOL>'<STR_LIT>': request.app().make('<STR_LIT>')<EOL>})<EOL> | Show the welcome page.
Arguments:
view {masonite.view.View} -- The Masonite view class.
Application {config.application} -- The application config module.
Returns:
masonite.view.View -- The Masonite view class. | f15646:c0:m0 |
def up(self): | with self.schema.create('<STR_LIT>') as table:<EOL><INDENT>table.increments('<STR_LIT:id>')<EOL>table.string('<STR_LIT:name>')<EOL>table.string('<STR_LIT:email>').unique()<EOL>table.string('<STR_LIT:password>')<EOL>table.string('<STR_LIT>').nullable()<EOL>table.timestamp('<STR_LIT>').nullable()<EOL>table.timestamps()<E... | Run the migrations. | f15649:c0:m0 |
def down(self): | self.schema.drop('<STR_LIT>')<EOL> | Revert the migrations. | f15649:c0:m1 |
def run(self): | self.factory.register(User, self.users_factory)<EOL>self.factory(User, <NUM_LIT:50>).create()<EOL> | Run the database seeds. | f15650:c0:m0 |
def run(self): | self.call(UserTableSeeder)<EOL> | Run the database seeds. | f15651:c0:m0 |
def app(environ, start_response): | from wsgi import container<EOL>"""<STR_LIT>"""<EOL>container.bind('<STR_LIT>', environ)<EOL>"""<STR_LIT>"""<EOL>try:<EOL><INDENT>for provider in container.make('<STR_LIT>'):<EOL><INDENT>container.resolve(provider.boot)<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>container.make('<STR_LIT>').load_exception(e)<... | The WSGI Application Server.
Arguments:
environ {dict} -- The WSGI environ dictionary
start_response {WSGI callable}
Returns:
WSGI Response | f15654:m0 |
def db_for_read(self, model, **hints): | if model._meta.app_label == '<STR_LIT>':<EOL><INDENT>return DUAS_DB_ROUTE_PREFIX<EOL><DEDENT>return None<EOL> | Attempts to read auth models go to duashttp. | f15658:c0:m0 |
def db_for_write(self, model, **hints): | if model._meta.app_label == '<STR_LIT>':<EOL><INDENT>if not DUAS_ENABLE_DB_WRITE:<EOL><INDENT>raise ImproperlyConfigured(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>return DUAS_DB_ROUTE_PREFIX<EOL><DEDENT>return None<EOL> | Attempts to write auth models go to duashttp. | f15658:c0:m1 |
def allow_relation(self, obj1, obj2, **hints): | if obj1._meta.app_label == '<STR_LIT>' orobj2._meta.app_label == '<STR_LIT>':<EOL><INDENT>return True<EOL><DEDENT>return None<EOL> | Allow relations if a model in the auth app is involved. | f15658:c0:m2 |
def allow_migrate(self, db, model): | if db == DUAS_DB_ROUTE_PREFIX:<EOL><INDENT>return model._meta.app_label == '<STR_LIT>'<EOL><DEDENT>elif model._meta.app_label == '<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>return None<EOL> | Make sure the auth app only appears in the 'duashttp'
database. | f15658:c0:m3 |
def get_guid(self): | return int('<STR_LIT>' % self.guid, <NUM_LIT:2>)<EOL> | gives int guid number instead of 01010.. sequence
:rtype: int
:return: guid | f15660:c2:m1 |
def get_digest(self): | a, b = struct.unpack('<STR_LIT>', self.digest)<EOL>return (a << <NUM_LIT:64>) | b<EOL> | return int uuid number for digest
:rtype: int
:return: digest | f15660:c5:m4 |
def get_blob_hash(self, h=hashlib.md5): | assert callable(h)<EOL>return h(self.get_blob_data())<EOL> | get hash instance of blob content
:param h: callable hash generator
:type h: builtin_function_or_method
:rtype: _hashlib.HASH
:return: hash instance | f15660:c5:m5 |
def get_blob_data(self, tag_target='<STR_LIT>', force=False): | if hasattr(self, '<STR_LIT>') and not force:<EOL><INDENT>return self._blob_data<EOL><DEDENT>if six.PY2:<EOL><INDENT>self._blob_data = six.binary_type('<STR_LIT>')<EOL><DEDENT>elif six.PY3:<EOL><INDENT>self._blob_data = six.binary_type('<STR_LIT>', encoding='<STR_LIT:ascii>')<EOL><DEDENT>asset_contents = self.contents.f... | get asset version content using pg large object streams
:param bool force: False by default, forces get content from database
instead of using cached value
:rtype: str
:return: content in raw format | f15660:c5:m6 |
@action(methods=['<STR_LIT:GET>', ])<EOL><INDENT>def blob(self, request, pk=None):<DEDENT> | obj = self.get_object_or_none()<EOL>if obj:<EOL><INDENT>blob = obj.get_blob_data()<EOL>content_type = '<STR_LIT>'<EOL>response = HttpResponse(blob, content_type=content_type,<EOL>status=status.HTTP_200_OK)<EOL>response['<STR_LIT>'] = (<EOL>'<STR_LIT>' % obj.name<EOL>)<EOL>return response<EOL><DEDENT>return HttpResponse... | fetch large object from pg and gives it back to user via HTTP 1.1
request
:param request: django request instance
:param pk: requested resource primary key
:rtype: django.http.HttpResponse
:rtype: HttpResponse
:return: file with its filename stored in database | f15662:c0:m0 |
def freeze(): | installations = {}<EOL>for dist in get_installed_distributions():<EOL><INDENT>req = pip.FrozenRequirement.from_dist(dist, [], find_tags=False)<EOL>installations[req.name] = req<EOL><DEDENT>return [str(installation).rstrip() for installation in<EOL>sorted(installations.values(), key=lambda x: x.name.lower())]<EOL> | Show arguments to require() to recreate what has been installed | f15664:m0 |
def require(*args, **kwargs): | <EOL>if not args and not kwargs:<EOL><INDENT>return freeze()<EOL><DEDENT>requirements = list(args)<EOL>extra = ['<STR_LIT>'.format(kw, kwargs[kw]) for kw in kwargs]<EOL>requirements.extend(extra)<EOL>args = ['<STR_LIT>', '<STR_LIT>']<EOL>args.extend(requirements)<EOL>pip.main(args)<EOL> | Install a set of packages using pip
This is designed to be an interface for IPython notebooks that
replicates the requirements.txt pip format. This lets notebooks
specify which versions of packages they need inside the notebook
itself.
This function is the general-purpose interface that lets
the caller specify any ve... | f15664:m1 |
def color(txt, color=WHITE, bold=True, bgcolor=None, inverse=False): | boldtxt = "<STR_LIT:0>"<EOL>if bold:<EOL><INDENT>boldtxt = "<STR_LIT:1>"<EOL><DEDENT>colortxt = "<STR_LIT>"<EOL>if color is not None:<EOL><INDENT>colortxt = "<STR_LIT>".format(<NUM_LIT:30> + color)<EOL><DEDENT>bgcolortxt = "<STR_LIT>"<EOL>if bgcolor is not None:<EOL><INDENT>bgcolortxt = "<STR_LIT>".format(<NUM_LIT> + b... | Construct string to use ANSI color escapes around text | f15667:m0 |
def table_of_result(self, result): | rows = []<EOL>def add(label, lst, style):<EOL><INDENT>for test, backtrace in lst:<EOL><INDENT>rows.append([label, result.getDescription(test), style])<EOL><DEDENT><DEDENT>add(CHECK, result.successes, u'<STR_LIT>')<EOL>add(CROSS, result.failures, u'<STR_LIT>')<EOL>add(HEAVY_CROSS, result.errors, u'<STR_LIT>')<EOL>add(SK... | Convert unittest Result object into HTML table | f15667:c3:m1 |
def summary_of_result(self, result, timeTaken): | run = result.testsRun<EOL>expectedFails = unexpectedSuccesses = skipped = <NUM_LIT:0><EOL>try:<EOL><INDENT>results = map(len, (result.expectedFailures,<EOL>result.unexpectedSuccesses,<EOL>result.skipped))<EOL>expectedFails, unexpectedSuccesses, skipped = results<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><... | Formulate paragraph summary line at end | f15667:c3:m2 |
def list_of_errors(self, result): | separator = u'<STR_LIT>' <EOL>res = []<EOL>def describe(style, tag, lst):<EOL><INDENT>for test, err in lst:<EOL><INDENT>headline = u"<STR_LIT>".format(style, tag, result.getDescription(test))<EOL>body = u"<STR_LIT>".format(u'<STR_LIT>', err)<EOL>res.append(separator)<EOL>res.append(headline)<EOL>res.append(body)<EOL><D... | Make list of errors | f15667:c3:m3 |
def get_tape(self, start=<NUM_LIT:0>, end=<NUM_LIT:10>): | self.tape_start = start<EOL>self.tape_end = end<EOL>self.tape_length = end - start<EOL>tmp = '<STR_LIT:\n>'+"<STR_LIT:|>"+str(start)+"<STR_LIT>"<EOL>for i in xrange(len(self.tape[start:end])):<EOL><INDENT>if i == self.cur_cell:<EOL><INDENT>tmp += "<STR_LIT:[>" + str(self.tape[i]) + "<STR_LIT>"<EOL><DEDENT>else: tmp += ... | Pretty prints the tape values | f15671:c0:m4 |
def authenticate(url, username, password): | <EOL>s = requests.Session()<EOL>data = s.get(url).content<EOL>class LoginParser(HTMLParser):<EOL><INDENT>url = '<STR_LIT>'<EOL>def handle_starttag(self, tag, alist):<EOL><INDENT>attrs = dict(alist)<EOL>if tag == '<STR_LIT>':<EOL><INDENT>self.url = attrs['<STR_LIT:action>']<EOL><DEDENT><DEDENT><DEDENT>loginparser = Logi... | Queries an asset behind CMU's WebISO wall.
It uses Shibboleth authentication (see: http://dev.e-taxonomy.eu/trac/wiki/ShibbolethProtocol)
Note that you can use this to authenticate stuff beyond just grades! (any CMU service)
Sample usage:
s = authenticate('https://enr-apps.as.cmu.edu/audit/audit', '... | f15673:m0 |
def get_protractor_params(self): | return {<EOL>'<STR_LIT>': self.live_server_url<EOL>}<EOL> | A hook for adding params that protractor will receive. | f15676:c0:m2 |
def teardown_databases(self, old_config, options): | if len(old_config) > <NUM_LIT:1>:<EOL><INDENT>old_names, mirrors = old_config<EOL><DEDENT>else:<EOL><INDENT>old_names = old_config<EOL><DEDENT>for connection, old_name, destroy in old_names:<EOL><INDENT>if destroy:<EOL><INDENT>connection.creation.destroy_test_db(old_name, options['<STR_LIT>'])<EOL><DEDENT><DEDENT> | Destroys all the non-mirror databases. | f15677:c0:m2 |
def http_construct(args, unknown): | str_http = '<STR_LIT>'<EOL>b_httpSpecd = False<EOL>if '<STR_LIT>' in unknown:<EOL><INDENT>try:<EOL><INDENT>str_httpArg = unknown[unknown.index('<STR_LIT>')+<NUM_LIT:1>]<EOL>unknown.remove('<STR_LIT>')<EOL>unknown.remove(str_httpArg)<EOL><DEDENT>except:<EOL><INDENT>str_httpArg = "<STR_LIT>"<EOL><DEDENT>str_http = ... | Construct the --http <arg> from the args/unknown space -- relevant only for 'purl'.
:param args:
:param unknown:
:return: | f15680:m0 |
def zipdir(path, ziph, **kwargs): | str_arcroot = "<STR_LIT>"<EOL>for k, v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT>': str_arcroot = v<EOL><DEDENT>for root, dirs, files in os.walk(path):<EOL><INDENT>for file in files:<EOL><INDENT>str_arcfile = os.path.join(root, file)<EOL>if len(str_arcroot):<EOL><INDENT>str_arcname = str_arcroot.split('<STR_LIT... | Zip up a directory.
:param path:
:param ziph:
:param kwargs:
:return: | f15684:m0 |
def zip_process(**kwargs): | str_localPath = "<STR_LIT>"<EOL>str_zipFileName = "<STR_LIT>"<EOL>str_action = "<STR_LIT>"<EOL>str_arcroot = "<STR_LIT>"<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT:path>': str_localPath = v<EOL>if k == '<STR_LIT:action>': str_action = v<EOL>if k == '<STR_LIT>': ... | Process zip operations.
:param kwargs:
:return: | f15684:m1 |
def base64_process(**kwargs): | str_fileToSave = "<STR_LIT>"<EOL>str_fileToRead = "<STR_LIT>"<EOL>str_action = "<STR_LIT>"<EOL>data = None<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT:action>': str_action = v<EOL>if k == '<STR_LIT>': data = v<EOL>if k == '<STR_LIT... | Process base64 file io | f15684:m2 |
def storage_resolveBasedOnKey(self, *args, **kwargs): | global Gd_internalvar<EOL>d_msg = {<EOL>'<STR_LIT:action>': '<STR_LIT>',<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>}<EOL>str_key = "<STR_LIT>"<EOL>b_status = False<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT:key>': str_key = v<EOL><DED... | Call the remote service and ask for the storage location based on the key.
:param args:
:param kwargs:
:return: | f15684:c0:m3 |
def remoteLocation_resolveSimple(self, d_remote): | b_status = False<EOL>str_remotePath = "<STR_LIT>"<EOL>if '<STR_LIT:path>' in d_remote.keys():<EOL><INDENT>str_remotePath = d_remote['<STR_LIT:path>']<EOL>b_status = True<EOL><DEDENT>if '<STR_LIT:key>' in d_remote.keys():<EOL><INDENT>str_remotePath = d_remote['<STR_LIT:key>']<EOL>b_status = True<... | Resolve the remote "path" location by returning either the
'path' or 'key' parameter in the 'remote' JSON record.
:param d_remote:
:return: | f15684:c0:m4 |
def remoteLocation_resolve(self, d_remote): | b_status = False<EOL>str_remotePath = "<STR_LIT>"<EOL>if '<STR_LIT:path>' in d_remote.keys():<EOL><INDENT>str_remotePath = d_remote['<STR_LIT:path>']<EOL>b_status = True<EOL><DEDENT>if '<STR_LIT:key>' in d_remote.keys():<EOL><INDENT>d_ret = self.storage_resolveBasedOnKey(key = d_remote['<STR_LIT:key>']... | Resolve the remote path location
:param d_remote: the "remote" specification
:return: a string representation of the remote path | f15684:c0:m5 |
def man(self, **kwargs): | str_man = '<STR_LIT>'<EOL>str_amount = '<STR_LIT>'<EOL>for k, v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT>': str_man = v<EOL>if k == '<STR_LIT>': str_amount = v<EOL><DEDENT>if str_man == '<STR_LIT>':<EOL><INDENT>str_commands = """<STR_LIT>""" + Colors.GREEN + """<STR_LIT>""" + Colors.WHITE + ""... | Print some man for each understood command | f15684:c0:m6 |
def pull_core(self, **kwargs): | str_ip = self.str_ip<EOL>str_port = self.str_port<EOL>verbose = <NUM_LIT:0><EOL>d_msg = {}<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT>': str_ip = v<EOL>if k == '<STR_LIT:port>': str_port = v<EOL>if k == '<STR_LIT>': d_msg =... | Just the core of the pycurl logic. | f15684:c0:m9 |
def pullPath_core(self, **kwargs): | d_msg = self.d_msg<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT>': d_msg = v<EOL><DEDENT>str_response = self.pull_core(msg = d_msg)<EOL>if len(str_response) < <NUM_LIT>:<EOL><INDENT>b_response = False<EOL>b_status = False<EOL>try:<EOL><INDENT>if self.b_httpResponseBodyParse:<EOL><... | Just the core of the pycurl logic. | f15684:c0:m10 |
def pullPath_compress(self, d_msg, **kwargs): | <EOL>d_meta = d_msg['<STR_LIT>']<EOL>if '<STR_LIT>' in d_meta:<EOL><INDENT>d_local = d_meta['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT:to>' in d_meta:<EOL><INDENT>d_local = d_meta['<STR_LIT:to>']<EOL><DEDENT>str_localPath = d_local['<STR_LIT:path>']<EOL>d_transport ... | This pulls a compressed path from a remote host/location.
Zip archives are universally unpacked to
/tmp/unpack-<uuid.uuid4()>
and then the file contents are moved to the actual destination
directory. In shell, this would be:
mkdir /tmp/unpack-<uuid.uuid4()>
cp file.zip /tmp/unpack-<uuid.uuid4()>
un... | f15684:c0:m11 |
def pullPath_copy(self, d_msg, **kwargs): | <EOL>d_meta = d_msg['<STR_LIT>']<EOL>d_local = d_meta['<STR_LIT>']<EOL>str_localPath = d_local['<STR_LIT:path>']<EOL>d_remote = d_meta['<STR_LIT>']<EOL>d_transport = d_meta['<STR_LIT>']<EOL>d_copy = d_transport['<STR_LIT>']<EOL>d_curl =... | Handle the "copy" pull operation | f15684:c0:m12 |
def path_remoteLocationCheck(self, d_msg, **kwargs): | <EOL>d_pull = self.pullPath_core()<EOL>return d_pull<EOL> | This method checks if the "remote" path is valid. | f15684:c0:m13 |
def path_localLocationCheck(self, d_msg, **kwargs): | b_pull = False<EOL>d_meta = d_msg['<STR_LIT>']<EOL>if '<STR_LIT>' in d_meta:<EOL><INDENT>if d_meta['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>b_pull = True<EOL><DEDENT><DEDENT>if '<STR_LIT>' in d_meta:<EOL><INDENT>d_local = d_meta['<STR_LIT>']<EOL><DE... | Check if a path exists on the local filesystem
:param self:
:param kwargs:
:return: | f15684:c0:m14 |
def pushPath_copy(self, d_msg, **kwargs): | <EOL>d_meta = d_msg['<STR_LIT>']<EOL>d_local = d_meta['<STR_LIT>']<EOL>str_localPath = d_local['<STR_LIT:path>']<EOL>d_remote = d_meta['<STR_LIT>']<EOL>d_transport = d_meta['<STR_LIT>']<EOL>d_copy = d_transport['<STR_LIT>']<EOL>d_curl =... | Handle the "copy" pull operation | f15684:c0:m18 |
def pathOp_do(self, d_msg, **kwargs): | d_meta = d_msg['<STR_LIT>']<EOL>b_OK = True<EOL>d_ret = {}<EOL>str_action = "<STR_LIT>"<EOL>for k,v, in kwargs.items():<EOL><INDENT>if k == '<STR_LIT:action>': str_action = v<EOL><DEDENT>if not '<STR_LIT>' in d_meta:<EOL><INDENT>d_transport = {<EOL>"<STR_LIT>": ... | Entry point for path-based push/pull calls.
Essentially, this method is the central dispatching nexus to various
specialized push operations. | f15684:c0:m19 |
def server_ctlQuit(self, d_msg): | d_shutdown = {}<EOL>d_meta = d_msg['<STR_LIT>']<EOL>d_meta['<STR_LIT>'] = {<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>self.dp.qprint('<STR_LIT>', level = <NUM_LIT:1>, comms ='<STR_LIT:status>')<EOL>try:<EOL><INDENT>d_shutdown = self.push_core(d_msg)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>return d_... | :return: d_shutdown shut down JSON message from remote service. | f15684:c0:m20 |
def pushPath(self, d_msg, **kwargs): | return self.pathOp_do(d_msg, action = '<STR_LIT>')<EOL> | Push data to a remote server using pycurl.
Essentially, this method is the central dispatching nexus to various
specialized push operations. | f15684:c0:m21 |
def pullPath(self, d_msg, **kwargs): | return self.pathOp_do(d_msg, action = '<STR_LIT>')<EOL> | Pulls data from a remote server using pycurl.
This method assumes that a prior call has "setup" a remote fileio
listener and has the ip:port of that instance.
Essentially, this method is the central dispatching nexus to various
specialized pull operations.
:param d_msg:
:param kwargs:
:return: | f15684:c0:m22 |
def httpResponse_bodyParse(self, **kwargs): | str_response = '<STR_LIT>'<EOL>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT>': str_response = v<EOL><DEDENT>try:<EOL><INDENT>str_body = str_response.split('<STR_LIT>')[<NUM_LIT:1>]<EOL>d_body = yaml.load(str_body)<EOL>str_body = json.dumps(d_body)<EOL><DEDENT>except:<EOL><INDENT... | Returns the *body* from a http response.
:param kwargs: response = <string>
:return: the <body> from the http <string> | f15684:c0:m24 |
def __call__(self, *args, **kwargs): | str_action = '<STR_LIT>'<EOL>http = '<STR_LIT>'<EOL>for key,val in kwargs.items():<EOL><INDENT>if key == '<STR_LIT>':<EOL><INDENT>self.str_msg = val<EOL>self.d_msg = json.loads(self.str_msg)<EOL><DEDENT>if key == '<STR_LIT:http>': self.httpStr_parse(http = val)<EOL>if key == '<STR_LIT... | Main entry point for "calling".
:param self:
:param kwargs:
:return: | f15684:c0:m25 |
def prepare_value(self, value): | if value is None and self.required:<EOL><INDENT>choices =list(self.choices)<EOL>if len(choices) == <NUM_LIT:1>:<EOL><INDENT>value = choices[<NUM_LIT:0>][<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return super(TemplateChoiceField, self).prepare_value(value)<EOL> | To avoid evaluating the lazysorted callable more than necessary to
establish a potential initial value for the field, we do it here.
If there's
- only one template choice, and
- the field is required, and
- there's no prior initial set (either by being bound or by being set
higher up the stack
then forcibly select t... | f15694:c2:m1 |
def from_cached(instance): | loaders = instance.loaders<EOL>for result in get_results_from_registry(loaders):<EOL><INDENT>yield result<EOL><DEDENT> | Just go and look at the registry again using the child loaders... | f15696:m2 |
def needs_quotes( s ): | <EOL>if s in dot_keywords:<EOL><INDENT>return False<EOL><DEDENT>chars = [ord(c) for c in s if ord(c)><NUM_LIT> or ord(c)==<NUM_LIT:0>]<EOL>if chars and not id_re_dbl_quoted.match(s) and not id_re_html.match(s):<EOL><INDENT>return True<EOL><DEDENT>for test_re in [id_re_alpha_nums, id_re_num,<EOL>id_re_dbl_quoted, id_re_... | Checks whether a string is a dot language ID.
It will check whether the string is solely composed
by the characters allowed in an ID or not.
If the string is one of the reserved keywords it will
need quotes too but the user will need to add them
manually. | f15701:m4 |
def quote_if_necessary(s): | if isinstance(s, bool):<EOL><INDENT>if s is True:<EOL><INDENT>return '<STR_LIT:True>'<EOL><DEDENT>return '<STR_LIT:False>'<EOL><DEDENT>if not isinstance( s, str_type):<EOL><INDENT>return s<EOL><DEDENT>if not s:<EOL><INDENT>return s<EOL><DEDENT>if needs_quotes(s):<EOL><INDENT>replace = {'<STR_LIT:">' : r'<STR_LIT>',<EO... | Enclode attribute value in quotes, if needed. | f15701:m5 |
def graph_from_dot_data(s): | return dot_parser.parse_dot_data(s)<EOL> | Load graphs from DOT description in string `s`.
@param s: string in [DOT language](
https://en.wikipedia.org/wiki/DOT_(graph_description_language))
@return: Graphs that result from parsing.
@rtype: `list` of `pydot.Dot` | f15701:m6 |
def graph_from_dot_file(path, encoding=None): | with io.open(path, '<STR_LIT>', encoding=encoding) as f:<EOL><INDENT>s = f.read()<EOL><DEDENT>if not PY3:<EOL><INDENT>s = unicode(s)<EOL><DEDENT>graphs = graph_from_dot_data(s)<EOL>return graphs<EOL> | Load graphs from DOT file at `path`.
@param path: to DOT file
@param encoding: as passed to `io.open`.
For example, `'utf-8'`.
@return: Graphs that result from parsing.
@rtype: `list` of `pydot.Dot` | f15701:m7 |
def graph_from_edges(edge_list, node_prefix='<STR_LIT>', directed=False): | if directed:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>for edge in edge_list:<EOL><INDENT>if isinstance(edge[<NUM_LIT:0>], str):<EOL><INDENT>src = node_prefix + edge[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>src = node_prefix + str(edg... | Creates a basic graph out of an edge list.
The edge list has to be a list of tuples representing
the nodes connected by the edge.
The values can be anything: bool, int, float, str.
If the graph is undirected by default, it is only
calculated from one of the symmetric halves of the matrix. | f15701:m8 |
def graph_from_adjacency_matrix(matrix, node_prefix= u'<STR_LIT>', directed=False): | node_orig = <NUM_LIT:1><EOL>if directed:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>for row in matrix:<EOL><INDENT>if not directed:<EOL><INDENT>skip = matrix.index(row)<EOL>r = row[skip:]<EOL><DEDENT>else:<EOL><INDENT>skip = <NUM_LIT:0><... | Creates a basic graph out of an adjacency matrix.
The matrix has to be a list of rows of values
representing an adjacency matrix.
The values can be anything: bool, int, float, as long
as they can evaluate to True or False. | f15701:m9 |
def graph_from_incidence_matrix(matrix, node_prefix='<STR_LIT>', directed=False): | node_orig = <NUM_LIT:1><EOL>if directed:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>for row in matrix:<EOL><INDENT>nodes = []<EOL>c = <NUM_LIT:1><EOL>for node in row:<EOL><INDENT>if node:<EOL><INDENT>nodes.append(c*node)<EOL><DEDENT>c +=... | Creates a basic graph out of an incidence matrix.
The matrix has to be a list of rows of values
representing an incidence matrix.
The values can be anything: bool, int, float, as long
as they can evaluate to True or False. | f15701:m10 |
def __get_attribute__(self, attr): | attr_val = self.obj_dict['<STR_LIT>'].get(attr, None)<EOL>if attr_val is None:<EOL><INDENT>default_node_name = self.obj_dict['<STR_LIT:type>']<EOL>if default_node_name in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>default_node_name = '<STR_LIT>'<EOL><DEDENT>g = self.get_parent_graph()<EOL>if g is not None:<EO... | Look for default attributes for this node | f15701:c1:m2 |
def set(self, name, value): | self.obj_dict['<STR_LIT>'][name] = value<EOL> | Set an attribute value by name.
Given an attribute 'name' it will set its value to 'value'.
There's always the possibility of using the methods:
set_'name'(value)
which are defined for all the existing attributes. | f15701:c1:m5 |
def get(self, name): | return self.obj_dict['<STR_LIT>'].get(name, None)<EOL> | Get an attribute value by name.
Given an attribute 'name' it will get its value.
There's always the possibility of using the methods:
get_'name'()
which are defined for all the existing attributes. | f15701:c1:m6 |
def set_name(self, node_name): | self.obj_dict['<STR_LIT:name>'] = node_name<EOL> | Set the node's name. | f15701:c4:m2 |
def get_name(self): | return self.obj_dict['<STR_LIT:name>']<EOL> | Get the node's name. | f15701:c4:m3 |
def get_port(self): | return self.obj_dict['<STR_LIT:port>']<EOL> | Get the node's port. | f15701:c4:m4 |
def to_string(self): | <EOL>node = quote_if_necessary(self.obj_dict['<STR_LIT:name>'])<EOL>node_attr = list()<EOL>for attr in sorted(self.obj_dict['<STR_LIT>']):<EOL><INDENT>value = self.obj_dict['<STR_LIT>'][attr]<EOL>if value == '<STR_LIT>':<EOL><INDENT>value = '<STR_LIT>'<EOL><DEDENT>if value is not None:<EOL><INDENT>node_attr.append(<EOL... | Return string representation of node in DOT language. | f15701:c4:m6 |
def get_source(self): | return self.obj_dict['<STR_LIT>'][<NUM_LIT:0>]<EOL> | Get the edges source node name. | f15701:c5:m2 |
def get_destination(self): | return self.obj_dict['<STR_LIT>'][<NUM_LIT:1>]<EOL> | Get the edge's destination node name. | f15701:c5:m3 |
def __eq__(self, edge): | if not isinstance(edge, Edge):<EOL><INDENT>raise Error('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if self.get_parent_graph().get_top_graph_type() == '<STR_LIT>':<EOL><INDENT>if ( ( self.get_source() == edge.get_source() and<EOL>self.get_destination() == edge.get_destination() ) or<EOL>( edge.get_source() == self.get_dest... | Compare two edges.
If the parent graph is directed, arcs linking
node A to B are considered equal and A->B != B->A
If the parent graph is undirected, any edge
connecting two nodes is equal to any other
edge connecting the same nodes, A->B == B->A | f15701:c5:m5 |
def to_string(self): | src = self.parse_node_ref( self.get_source() )<EOL>dst = self.parse_node_ref( self.get_destination() )<EOL>if isinstance(src, frozendict):<EOL><INDENT>edge = [ Subgraph(obj_dict=src).to_string() ]<EOL><DEDENT>elif isinstance(src, int):<EOL><INDENT>edge = [ str(src) ]<EOL><DEDENT>else:<EOL><INDENT>edge = [ src ]<EOL><DE... | Return string representation of edge in DOT language. | f15701:c5:m7 |
def set_simplify(self, simplify): | self.obj_dict['<STR_LIT>'] = simplify<EOL> | Set whether to simplify or not.
If True it will avoid displaying equal edges, i.e.
only one edge between two nodes. removing the
duplicated ones. | f15701:c6:m10 |
def get_simplify(self): | return self.obj_dict['<STR_LIT>']<EOL> | Get whether to simplify or not.
Refer to set_simplify for more information. | f15701:c6:m11 |
def set_type(self, graph_type): | self.obj_dict['<STR_LIT:type>'] = graph_type<EOL> | Set the graph's type, 'graph' or 'digraph'. | f15701:c6:m12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.