text stringlengths 0 828 |
|---|
self.lines = options.get(""lines"") |
self.ignore = int(options.get('ignore')) |
if not self.compare_name: |
self.compare_name = ""%s_compare"" % self.current_name |
command = NASHVEGAS.get(""dumpdb"", ""pg_dump -s {dbname}"") |
print ""Getting schema for current database..."" |
current_sql = Popen( |
command.format(dbname=self.current_name), |
shell=True, |
stdout=PIPE |
).stdout.readlines() |
print ""Getting schema for fresh database..."" |
self.setup_database() |
connections[self.db].close() |
connections[self.db].settings_dict[""NAME""] = self.compare_name |
try: |
call_command(""syncdb"", interactive=False, verbosity=0, migrations=False) |
new_sql = Popen( |
command.format(dbname=self.compare_name).split(), |
stdout=PIPE |
).stdout.readlines() |
finally: |
connections[self.db].close() |
connections[self.db].settings_dict[""NAME""] = self.current_name |
self.teardown_database() |
print ""Outputing diff between the two..."" |
print """".join(difflib.unified_diff(normalize_sql(current_sql, self.ignore), |
normalize_sql(new_sql, self.ignore), |
n=int(self.lines)))" |
1811,"def render_widgets(kb_app: kb, |
sphinx_app: Sphinx, |
doctree: doctree, |
fromdocname: str, |
): |
"""""" Go through docs and replace widget directive with rendering """""" |
builder: StandaloneHTMLBuilder = sphinx_app.builder |
for node in doctree.traverse(widget): |
# Render the output |
w = sphinx_app.env.widgets.get(node.name) |
context = builder.globalcontext.copy() |
# Add in certain globals |
context['resources'] = sphinx_app.env.resources |
context['references'] = sphinx_app.env.references |
output = w.render(sphinx_app, context) |
# Put the output into the node contents |
listing = [nodes.raw('', output, format='html')] |
node.replace_self(listing)" |
1812,"def attr_string(filterKeys=(), filterValues=(), **kwargs): |
""""""Build a string consisting of 'key=value' substrings for each keyword |
argument in :kwargs: |
@param filterKeys: list of key names to ignore |
@param filterValues: list of values to ignore (e.g. None will ignore all |
key=value pairs that has that value. |
"""""" |
return ', '.join([str(k)+'='+repr(v) for k, v in kwargs.items() |
if k not in filterKeys and v not in filterValues])" |
1813,"def auth_string(self): |
"""""" |
Get the auth string. If the token is expired and auto refresh enabled, |
a new token will be fetched |
:return: the auth string |
:rtype: str |
"""""" |
if not self._token: |
self.execute() |
if not self._token.expired: |
return 'Bearer {}'.format(self._token.access_token) |
if self.auto_refresh: |
self.execute() |
return 'Bearer {}'.format(self._token.access_token) |
raise TokenExpired()" |
1814,"async def main(): |
""""""Get the data from a *hole instance."""""" |
async with aiohttp.ClientSession() as session: |
data = Hole('192.168.0.215', loop, session) |
await data.get_data() |
# Get the raw data |
print(json.dumps(data.data, indent=4, sort_keys=True)) |
print(""Status:"", data.status) |
print(""Domains being blocked:"", data.domains_being_blocked)" |
1815,"async def enable(): |
""""""Get the data from a *hole instance."""""" |
async with aiohttp.ClientSession() as session: |
data = Hole('192.168.0.215', loop, session, api_token=API_TOKEN) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.