function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def __init__(self):
'''initialize configuration'''
# mode of operation
self.mode = None
# mapping of targets to lists of backends to use when backing up / restoring them
self.target_backends = {}
# mapping of targets to lists of entities to include when backing up
... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def log_level_at_least(self, comparison):
return (comparison == 'quiet') or \
(comparison == 'normal' and self.log_level != 'quiet') or \
(comparison == 'verbose' and (self.log_level == 'verbose' or self.log_level == 'debug')) or \
(comparison == 'debug' and self.... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def __init__(self, config_file):
'''
Initialize the config file, specifying its path
@param file - the path to the file to load
'''
# if config file doesn't exist, just ignore
if not os.path.exists(config_file):
if snap.config.options.log_level_at_least("ver... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def string_to_array(string):
'''Static helper to convert a colon deliminated string to an array of strings'''
return string.split(':') | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def __get_bool(self, key, section='main'):
'''
Retreive the indicated boolean value from the config file
@param key - the string key corresponding to the boolean value to retrieve
@param section - the section to retrieve the value from
@returns - the value or False if not found
... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def __get_array(self, section='main'):
'''return array of key/value pairs from the config file section | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def __parse(self):
'''parse configuration out of the config file'''
for backend in SnapshotTarget.BACKENDS:
val = self.__get_bool(backend)
if val is not None:
snap.config.options.target_backends[backend] = val
else:
val = self.__get_st... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def read_config(self):
# add conf stored in resources if running from local checkout
CONFIG_FILES.append(os.path.join(os.path.dirname(__file__), "..", "resources", "snap.conf"))
for config_file in CONFIG_FILES:
ConfigFile(config_file) | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def verify_integrity(self):
'''
verify the integrity of the current option set
@raises - ArgError if the options are invalid
'''
if snap.config.options.mode == None: # mode not specified
raise snap.exceptions.ArgError("Must specify backup or restore")
if snap... | movitto/snap | [
22,
2,
22,
6,
1320352462
] |
def __init__(self, engine, txid, msg, callback=None, max_duration=5000, max_concurrency=3):
self.engine = engine
self.callback = callback
self.machine = Machine(model=self,
states=self.states,
transitions=self.transitions,
... | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def query(self):
pass | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def is_complete(self):
return self.state in ['complete', 'timedout'] | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def pack_request(self):
return None | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def unpack_response(content):
return None | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def pack_response(content):
return None | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def duration(self):
return time.time() * 1000 - self.start | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def _send_query(self):
pass | shendo/peerz | [
8,
3,
8,
2,
1402811281
] |
def accept_upload(conf, dud, event_emitter):
'''
Accept the upload and move its data to the right places.
'''
job_success = dud.get('X-Spark-Success') == 'Yes'
job_id = dud.get('X-Spark-Job')
# mark job as accepted and done
with session_scope() as session:
job = session.query(Job).... | lkorigin/laniakea | [
20,
8,
20,
1,
1465596960
] |
def import_files_from(conf, incoming_dir):
'''
Import files from an untrusted incoming source.
IMPORTANT: We assume that the uploader can not edit their files post-upload.
If they could, we would be vulnerable to timing attacks here.
'''
emitter = EventEmitter(LkModule.RUBICON)
for dud_fil... | lkorigin/laniakea | [
20,
8,
20,
1,
1465596960
] |
def ready(self):
super(PeopleAppConfig, self).ready() | kartoza/geonode | [
6,
17,
6,
113,
1439813567
] |
def choose(n, k):
if k > n:
return 0
elif n < MOD:
return (fact[n]/fact[n-k]/fact[k])%MOD
else:
prod = 1
while n > 0:
prod *= choose(n%MOD, k%MOD)
prod %= MOD
n /= MOD
k /= MOD
return prod | KirarinSnow/Google-Code-Jam | [
84,
38,
84,
1,
1276377660
] |
def set_assets_node(self, assets):
if not isinstance(assets, list):
assets = [assets]
node_id = self.request.query_params.get('node_id')
if not node_id:
return
node = get_object_or_none(Node, pk=node_id)
if not node:
return
node.assets.... | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_object(self):
asset_pk = self.kwargs.get('pk')
asset = get_object_or_404(Asset, pk=asset_pk)
return asset.platform | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def check_object_permissions(self, request, obj):
if request.method.lower() in ['delete', 'put', 'patch'] and obj.internal:
self.permission_denied(
request, message={"detail": "Internal platform"}
)
return super().check_object_permissions(request, obj) | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def perform_assets_task(self, serializer):
data = serializer.validated_data
action = data['action']
assets = data.get('assets', [])
if action == "refresh":
task = update_assets_hardware_info_manual.delay(assets)
else:
# action == 'test':
task =... | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def set_task_to_serializer_data(self, serializer, task):
data = getattr(serializer, '_data', {})
data["task"] = task.id
setattr(serializer, '_data', data) | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def create(self, request, *args, **kwargs):
pk = self.kwargs.get('pk')
request.data['asset'] = pk
request.data['assets'] = [pk]
return super().create(request, *args, **kwargs) | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def perform_asset_task(self, serializer):
data = serializer.validated_data
action = data['action']
if action not in ['push_system_user', 'test_system_user']:
return
asset = data['asset']
system_users = data.get('system_users')
if not system_users:
... | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_queryset(self):
asset_id = self.kwargs.get('pk')
asset = get_object_or_404(Asset, pk=asset_id)
if not asset.domain:
return []
queryset = asset.domain.gateways.filter(protocol='ssh')
return queryset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_object(self):
asset_id = self.kwargs.get('pk')
asset = get_object_or_404(Asset, pk=asset_id)
return asset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_queryset(self):
perms = self.get_asset_related_perms()
users = User.objects.filter(
Q(assetpermissions__in=perms) | Q(groups__assetpermissions__in=perms)
).distinct()
return users | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_queryset(self):
perms = self.get_asset_related_perms()
user_groups = UserGroup.objects.filter(assetpermissions__in=perms).distinct()
return user_groups | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_object(self):
asset_id = self.kwargs.get('pk')
asset = get_object_or_404(Asset, pk=asset_id)
return asset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
queryset = self.filter_asset_related(queryset)
return queryset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
queryset = self.filter_user_related(queryset)
queryset = queryset.distinct()
return queryset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def get_perm_user(self):
user_id = self.kwargs.get('perm_user_id')
user = get_object_or_404(User, pk=user_id)
return user | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
queryset = self.filter_user_group_related(queryset)
queryset = queryset.distinct()
return queryset | jumpserver/jumpserver | [
19948,
4806,
19948,
134,
1404446099
] |
def main():
usage = "%prog [options] <song-set> <results-file0> [<results-file1> ...]"
parser = OptionParser(usage=usage)
parser.add_option("--popt", "--parser-options", dest="popts", action="append", help="specify options for the parser that interprets the gold standard annotations. Type '--popt help' to g... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __init__(
self,
ic: IdentityController,
api_factory: APIFactory,
start_sub: str = None):
Gtk.Window.__init__(self, title='Something For Reddit',
icon_name='today.sam.reddit-is-gtk')
self.add_events(Gdk.EventMask.KEY_PRESS_MA... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def connect_api(self, api: RedditAPI):
start_sub = None
if start_sub is None:
start_sub = get_settings()['default-sub']
if self._api is not None:
# TODO: swap right panel
print('Swapping', self._api, 'for', api)
start_sub = self._sublist.get_uri(... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def do_event(self, event):
if event.type != Gdk.EventType.KEY_PRESS:
return
if isinstance(self.get_focus(), (Gtk.TextView, Gtk.Entry)):
return
if event.keyval == Gdk.KEY_F6:
self._subentry.focus()
return True
if event.keyval == Gdk.KEY_1:
... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def load_uri_from_label(self, uri):
is_relative = not uri.startswith('http')
is_reddit = re.match('https?:\/\/(www\.|np\.)?reddit\.com\/', uri)
if is_relative or is_reddit:
self.goto_reddit_uri(uri)
return
self._stack.set_visible_child(self._webview_bin)
... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def _make_header(self):
self._header_paned = Gtk.Paned()
self.set_titlebar(self._header_paned)
self._left_header = Gtk.HeaderBar()
layout = Gtk.Settings.get_default().props.gtk_decoration_layout
self._left_header.set_decoration_layout(layout.split(':')[0])
self._right_h... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def get_sublist(self):
return self._sublist | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def goto_sublist(self, to):
'''
Public api for children:
widget.get_toplevel().goto_sublist('/u/samdroid_/overview')
'''
self._sublist.goto(to)
self._subentry.goto(to) | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __cv_got_post_data_cb(self, cv, post):
if not post.get('is_self') and 'url' in post:
self.__new_other_pane_cb(None, post['url'], cv, True) | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __subentry_escape_me_cb(self, entry):
self._sublist.focus() | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __init__(self, ic: IdentityController, api_factory: APIFactory):
Gtk.Application.__init__(self,
application_id='today.sam.reddit-is-gtk')
self.connect('startup', self.__do_startup_cb)
GLib.set_application_name("Something For Reddit")
GLib.set_prgname(... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def goto_reddit_uri(self, uri):
if self._w is None:
self._queue_uri = uri
else:
self._w.goto_reddit_uri(uri) | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __do_startup_cb(self, app):
actions = [('about', self.__about_cb),
('quit', self.__quit_cb),
('issues', self.__issues_cb),
('shortcuts', self.__shortcuts_cb),
('settings', self.__settings_cb)]
for name, cb in actions:
... | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __issues_cb(self, action, param):
webviews.open_uri_external(
'https://github.com/samdroid-apps/something-for-reddit/issues') | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def __shortcuts_cb(self, action, param):
builder = Gtk.Builder.new_from_resource(
'/today/sam/reddit-is-gtk/shortcuts-window.ui')
builder.get_object('window').show() | samdroid-apps/something-for-reddit | [
163,
15,
163,
18,
1459079393
] |
def draw_background(setup) :
canvas = setup['canvas']
image = Image.new('RGBA', canvas, tuple(setup['color']['back']))
background = Image.new('RGBA', canvas, (0,0,0,0))
draw = ImageDraw.Draw(background)
stars = [[ int(p * random()) for p in canvas ] for x in range(400) ]
scale = lambda x, r : x + r * (min(canva... | vojtatom/planets | [
2,
1,
2,
3,
1491924309
] |
def apply_ray_effect(sun_image, setup) :
canvas = setup['canvas']
width, height = setup['canvas'][0], setup['canvas'][1]
decay = 0.8
density = 1.2
samples = 128
center = [ x / 2 for x in setup['canvas'] ]
list_of_pixels = list(sun_image.getdata())
new_image = []
print("starting postprocessing...")
for y in ... | vojtatom/planets | [
2,
1,
2,
3,
1491924309
] |
def create_sun(setup) :
canvas, size = setup['canvas'], setup['size']
d = min([x * 0.08 * 5 * size for x in canvas])
planet = [ (x - d) / 2 for x in canvas ]
planet.append(planet[0] + d)
planet.append(planet[1] + d)
setup['sun'] = planet
setup['diam'] = d
setup['rad'] = d / 2
setup['center'] = [ planet[0] + d... | vojtatom/planets | [
2,
1,
2,
3,
1491924309
] |
def sun(setup) :
setup = sun_setup(setup)
create_sun(setup)
image = draw_background(setup)
image = draw_sun(image, setup)
canvas = [ int(x / 2) for x in setup['canvas'] ]
resized = image.resize(canvas, Image.ANTIALIAS)
resized.save("test.png") | vojtatom/planets | [
2,
1,
2,
3,
1491924309
] |
def main(name, brief, debug, rec_debug, **unused_options):
global stack
if not os.path.isfile(name):
print(name, "is an invalid file name!", file=sys.stderr)
return 1
arch = get_archive(name)
stack.append((name, arch))
if debug or brief:
show_log(arch, rec_debug, brief)
... | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def usage():
print("U: go Up one level", file=sys.stderr)
print("O <name>: open embedded archive name", file=sys.stderr)
print("X <name>: extract name", file=sys.stderr)
print("Q: quit", file=sys.stderr) | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def get_data(name, arch):
if isinstance(arch.toc, dict):
(ispkg, pos, length) = arch.toc.get(name, (0, None, 0))
if pos is None:
return None
with arch.lib:
arch.lib.seek(arch.start + pos)
return zlib.decompress(arch.lib.read(length))
ndx = arch.toc.fin... | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def get_content(arch, recursive, brief, output):
if isinstance(arch.toc, dict):
toc = arch.toc
if brief:
for name, _ in toc.items():
output.append(name)
else:
output.append(toc)
else:
toc = arch.toc.data
for el in toc:
i... | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def get_archive_content(filename):
"""
Get a list of the (recursive) content of archive `filename`.
This function is primary meant to be used by runtests.
"""
archive = get_archive(filename)
stack.append((filename, archive))
output = []
get_content(archive, recursive=True, brief=True, o... | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def checkmagic(self):
""" Overridable.
Check to see if the file object self.lib actually has a file
we understand.
"""
self.lib.seek(self.start) # default - magic is at start of file.
if self.lib.read(len(self.MAGIC)) != self.MAGIC:
raise RuntimeError... | etherkit/OpenBeacon2 | [
13,
2,
13,
5,
1355386213
] |
def __init__(self, jss):
"""Initialize a new CommandFlush
Args:
jss: JSS object.
"""
self.jss = jss | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def url(self):
"""Return the path subcomponent of the url to this object."""
return self._endpoint_path | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def command_flush_for(self, id_type, command_id, status):
"""Flush commands for an individual device.
Args:
id_type (str): One of 'computers', 'computergroups',
'mobiledevices', or 'mobiledevicegroups'.
id_value (str, int, list): ID value(s) for the devices to
... | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def __init__(self, j, resource_type, id_type, _id, resource):
"""Prepare a new FileUpload.
Args:
j: A JSS object to POST the upload to.
resource_type:
String. Acceptable Values:
Attachments:
computers
... | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def save(self):
"""POST the object to the JSS."""
try:
response = self.jss.session.post(
self._upload_url, files=self.resource)
except PostError as error:
if error.status_code == 409:
raise PostError(error)
else:
... | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def __init__(self, jss):
"""Initialize a new LogFlush
Args:
jss: JSS object.
"""
self.jss = jss | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def url(self):
"""Return the path subcomponent of the url to this object."""
return self._endpoint_path | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def log_flush_for_interval(self, log_type, interval):
"""Flush logs for an interval of time.
Args:
log_type (str): Only documented type is "policies". This
will be applied by default if nothing is passed.
interval (str): Combination of "Zero", "One", "Two",
... | sheagcraig/python-jss | [
104,
40,
104,
10,
1402081132
] |
def setUp(self):
self.credentials = {
'username': 'testuser',
'password': 'test1234',
'email': 'test@mail.com'}
# Create a test Group
my_group, created = Group.objects.get_or_create(name='test_group')
# Add user to test Group
User.objects.get... | OpenDroneMap/WebODM | [
2125,
778,
2125,
82,
1470665302
] |
def test_views(self):
c = Client()
# Connecting to dashboard without auth redirects to /
res = c.get('/dashboard/', follow=True)
self.assertFalse(res.context['user'].is_authenticated)
self.assertRedirects(res, '/login/?next=/dashboard/')
res = c.get('/processingnode/1/'... | OpenDroneMap/WebODM | [
2125,
778,
2125,
82,
1470665302
] |
def test_default_group(self):
# It exists
self.assertTrue(Group.objects.filter(name='Default').count() == 1)
# Verify that all new users are assigned to default group
u = User.objects.create_user(username="default_user")
u.refresh_from_db()
self.assertTrue(u.groups.filte... | OpenDroneMap/WebODM | [
2125,
778,
2125,
82,
1470665302
] |
def _compute_is_paynet_contract(self):
transmit_method = self.env.ref("ebill_paynet.paynet_transmit_method")
for record in self:
record.is_paynet_contract = record.transmit_method_id == transmit_method | OCA/l10n-switzerland | [
49,
155,
49,
19,
1401971092
] |
def _check_paynet_account_number(self):
for contract in self:
if not contract.is_paynet_contract:
continue
if not contract.paynet_account_number:
raise ValidationError(
_("The Paynet ID is required for a Paynet contract.")
... | OCA/l10n-switzerland | [
49,
155,
49,
19,
1401971092
] |
def update(self):
result = {}
values = {'context': self.context}
body = self.content(args=values, template=self.template)['body']
item = self.adapt_item(body, self.viewid)
result['coordinates'] = {self.coordinates: [item]}
return result | ecreall/nova-ideo | [
22,
6,
22,
9,
1417421268
] |
def before_update(self):
self.action = self.request.resource_url(
self.context, 'novaideoapi',
query={'op': 'update_action_view',
'node_id': Restor.node_definition.id})
self.schema.widget = deform.widget.FormWidget(
css_class='deform novaideo-ajax-f... | ecreall/nova-ideo | [
22,
6,
22,
9,
1417421268
] |
def create_app(conf):
app = Flask(__name__)
app.config.update(conf)
Bootstrap(app)
babel = Babel(app)
app.register_blueprint(agherant.agherant, url_prefix='/agherant')
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(['en', 'it', 'sq'])
return ... | insomnia-lab/libreant | [
18,
8,
18,
62,
1416821512
] |
def __init__(self, **kwargs):
kwargs["decimal_places"] = 2
for f in ["min_value", "max_value"]:
if f in kwargs:
kwargs[f] = Decimal(kwargs[f]) / 100
super().__init__(**kwargs) | lafranceinsoumise/api-django | [
26,
9,
26,
14,
1492079465
] |
def clean(self, value):
value = super().clean(value)
return value and int(value * 100) | lafranceinsoumise/api-django | [
26,
9,
26,
14,
1492079465
] |
def __init__(
self, *, amount_choices=None, show_tax_credit=True, by_month=False, **kwargs | lafranceinsoumise/api-django | [
26,
9,
26,
14,
1492079465
] |
def amount_choices(self):
return self._amount_choices | lafranceinsoumise/api-django | [
26,
9,
26,
14,
1492079465
] |
def amount_choices(self, amount_choices):
self._amount_choices = amount_choices
if self.widget:
self.widget.attrs["data-amount-choices"] = json.dumps(self._amount_choices) | lafranceinsoumise/api-django | [
26,
9,
26,
14,
1492079465
] |
def dump_city(self, city):
return {
'confidence': city.confidence,
'geoname_id': city.geoname_id,
'name': city.name,
'names': city.names
} | CERT-BDF/Cortex-Analyzers | [
368,
340,
368,
188,
1484054590
] |
def dump_country(self, country):
return {
'confidence': country.confidence,
'geoname_id': country.geoname_id,
'iso_code': country.iso_code,
'name': country.name,
'names': country.names
} | CERT-BDF/Cortex-Analyzers | [
368,
340,
368,
188,
1484054590
] |
def dump_traits(self, traits):
return {
'autonomous_system_number': traits.autonomous_system_number,
'autonomous_system_organization': traits.autonomous_system_organization,
'domain': traits.domain,
'ip_address': traits.ip_address,
'is_anonymous_proxy'... | CERT-BDF/Cortex-Analyzers | [
368,
340,
368,
188,
1484054590
] |
def run(self):
Analyzer.run(self)
if self.data_type == 'ip':
try:
data = self.get_data()
city = geoip2.database.Reader(os.path.dirname(__file__) + '/GeoLite2-City.mmdb').city(data)
self.report({
'city': self.dump_city(cit... | CERT-BDF/Cortex-Analyzers | [
368,
340,
368,
188,
1484054590
] |
def materialize_actual_owners_remove(events: list):
for event in events:
properties = {'$pull': {'owners': event['from']}}
DeviceDomain.update_raw(event.get('components', []), properties)
return DeviceDomain.update_raw(event['devices'], properties) | eReuse/DeviceHub | [
2,
1,
2,
13,
1439187776
] |
def path_page(self, seo_url, **kwargs):
"""Handle SEO urls for ir.ui.views.
ToDo: Add additional check for field seo_url_parent. Otherwise it is
possible to use invalid url structures. For example: if you have two
pages 'study-1' and 'study-2' with the same seo_url_level and different
... | blooparksystems/website | [
10,
33,
10,
23,
1439476298
] |
def page(self, page, **opt):
try:
view = request.website.get_template(page)
if view.seo_url:
return request.redirect(view.get_seo_path()[0], code=301)
except:
pass
return super(Website, self).page(page, **opt) | blooparksystems/website | [
10,
33,
10,
23,
1439476298
] |
def test_imprint(app, client):
app.config["SKYLINES_IMPRINT"] = u"foobar"
res = client.get("/imprint")
assert res.status_code == 200
assert res.json == {u"content": u"foobar"} | skylines-project/skylines | [
367,
102,
367,
81,
1324989203
] |
def progress_callback(percentage):
sys.stdout.write(str(percentage) + "% ")
sys.stdout.flush()
# process all files so the user can use wildcards like *.wav | MTG/pycompmusic | [
27,
18,
27,
5,
1366895285
] |
def _is_file(f):
return isinstance(f, file) # noqa | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _is_file(f):
return isinstance(f, io.IOBase) | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _pipe_segment_with_colons(align, colwidth):
"""Return a segment of a horizontal line with optional colons which
indicate column's alignment (as in `pipe` output format)."""
w = colwidth
if align in ["right", "decimal"]:
return ('-' * (w - 1)) + ":"
elif align == "center":
return ... | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _mediawiki_row_with_attrs(separator, cell_values, colwidths, colaligns):
alignment = {"left": '',
"right": 'align="right"| ',
"center": 'align="center"| ',
"decimal": 'align="right"| '}
# hard-coded padding _around_ align attribute and value together
... | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _html_begin_table_without_header(colwidths_ignore, colaligns_ignore):
# this table header will be suppressed if there is a header row
return "\n".join(["<table>", "<tbody>"]) | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _moin_row_with_attrs(celltag, cell_values, colwidths, colaligns,
header=''):
alignment = {"left": '',
"right": '<style="text-align: right;">',
"center": '<style="text-align: center;">',
"decimal": '<style="text-align: right;">'}
... | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def _latex_row(cell_values, colwidths, colaligns, escrules=LATEX_ESCAPE_RULES):
def escape_char(c):
return escrules.get(c, c)
escaped_values = ["".join(map(escape_char, cell)) for cell in cell_values]
rowfmt = DataRow("", "&", "\\\\")
return _build_simple_row(escaped_values, rowfmt) | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
def escape_empty(val):
if isinstance(val, (_text_type, _binary_type)) and not val.strip():
return ".."
else:
return val | anlambert/tulip | [
2,
1,
2,
1,
1486498884
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.