code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
import asyncio
import logging
from aioredlock import Aioredlock, LockError, LockAcquiringError
async def basic_lock():
lock_manager = Aioredlock([{
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None
}])
if await lock_manager.is_locked("resource"):
print(... | joanvila/aioredlock | examples/basic_lock.py | Python | mit | 1,083 |
import logging
from datetime import datetime
class Subscriber(object):
OFF = 0
ON = 1
ALL = 2
QUERY = 'query'
def __init__(self, nick, status):
self.nick = nick
self.status = status
self.modes = [Subscriber.QUERY]
def to_dict(self):
return {key:value for key... | cthit/DreamTeamBots | anette/plugins/anette/subscriber.py | Python | mit | 2,213 |
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Integration tests for round-trip loading and saving various product
definitions.
"""
# Import iris_grib.tests f... | SciTools/iris-grib | iris_grib/tests/integration/round_trip/test_product_definition_section.py | Python | lgpl-3.0 | 2,800 |
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import sys
import os
import virtualenv as venv
"""
Colorful output
"""
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = "\033[1m"
def head(msg):
print(HEADER + msg + ENDC)
def info(msg):
... | ccgeom/ccg-notes | bin/env.py | Python | cc0-1.0 | 1,047 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-21 19:10
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('custom_image', '0001_initial'),
]
operations = [
... | stefanfoulis/django-filer | filer/test_utils/custom_image/migrations/0002_auto_20160621_1510.py | Python | bsd-3-clause | 823 |
from _aio import * # in libs/_aio.js
def _task(coro, Id, block):
async def _task():
block[Id] = None
try:
block[Id] = await coro
except Exception as e:
block[Id] = e
if not block[Id]:
del block[Id]
return _task()
async def gather(*coros, rat... | kikocorreoso/brython | www/src/Lib/browser/aio.py | Python | bsd-3-clause | 522 |
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# Copyright (c) 2012 VMware, Inc.
# Copyright (c) 2011 Citrix Systems, Inc.
# Copyright 2011 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. Yo... | shail2810/nova | nova/tests/unit/virt/vmwareapi/test_driver_api.py | Python | apache-2.0 | 101,271 |
# -*- coding: utf-8 -*-
import os
# Path to folder
PYHGNC_DIR = os.path.expanduser('~/.pyhgnc')
if not os.path.exists(PYHGNC_DIR):
os.mkdir(PYHGNC_DIR)
# Path to data folder
PYHGNC_DATA_DIR = os.path.join(PYHGNC_DIR, 'data')
if not os.path.exists(PYHGNC_DATA_DIR):
os.mkdir(PYHGNC_DATA_DIR)
# Path to logs fo... | LeKono/pyhgnc | src/pyhgnc/constants.py | Python | apache-2.0 | 770 |
from datetime import timedelta, datetime
from nose.tools import assert_equals
from copy import deepcopy
import linphone
import logging
import os
import sys
import time
import weakref
test_domain = "sipopen.example.org"
auth_domain = "sip.example.org"
test_username = "liblinphone_tester"
test_password = "secret"
test_... | madmanteam/linphone | tools/python/unittests/linphonetester.py | Python | gpl-2.0 | 31,962 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding M2M table for field last_read_by on 'Message'
m2m_table_name = d... | tsujamin/digi-approval | src/digiapproval_project/digiapproval_project/apps/digiapproval/migrations/0009_add_last_read_mm_auto.py | Python | gpl-3.0 | 8,804 |
'''
Copyright 2011 SRI International
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softw... | LearningRegistry/LRSignature | src/LRSignature/tests/__init__.py | Python | apache-2.0 | 643 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apach... | citrix-openstack-build/trove | trove/extensions/mgmt/host/service.py | Python | apache-2.0 | 2,035 |
from weakref import WeakValueDictionary, WeakKeyDictionary, _IterationGuard
def copy_wvd(self):
if self._pending_removals:
self._commit_removals()
new = WeakValueDictionary()
with _IterationGuard(self):
for key, wr in self.data.items():
o = wr()
if o is not None:
... | angr/angr | angr/misc/weakpatch.py | Python | bsd-2-clause | 1,446 |
import flask_testing
from flask import current_app
from flask import Response
from rdflib import URIRef
from typing import Optional, Dict
from depot.manager import DepotManager
class TestCase(flask_testing.TestCase):
def login_new_user(self, *, email: str = "user@example.com", password: str = "password", usernam... | tetherless-world/satoru | whyis/test/test_case.py | Python | apache-2.0 | 3,045 |
'''
1.create public network with Network segment
2.check dhcp ip address
@author Antony WeiJiang
'''
import zstackwoodpecker.test_lib as test_lib
import zstackwoodpecker.test_state as test_state
import zstackwoodpecker.test_util as test_util
import zstackwoodpecker.operations.resource_operations as res_ops
import zst... | zstackorg/zstack-woodpecker | integrationtest/vm/simulator/dhcp_server_ip/test_dhcp_for_networkSegment.py | Python | apache-2.0 | 2,159 |
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
requires = [
'grazyna>=0.5.3',
'pytest==2.7.2'
]
setup(
name='grazyna_rpg',
version='0.1',
description='RPG Mode',
long_description='RPG Mode',
classifiers=[],
author='Firemark',
... | firemark/grazyna-rpg | setup.py | Python | mit | 535 |
# -*- coding: utf-8 -*-
#
# catalog-harvesting documentation build configuration file, created by
# sphinx-quickstart on Wed Jun 22 10:56:24 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated ... | ioos/catalog-harvesting | docs/source/conf.py | Python | mit | 9,446 |
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from master import gitiles_poller
def Update(config, c):
chromium_src_poller = gitiles_poller.GitilesPoller(
config.Master.git_server_url + '/c... | eunchong/build | masters/master.chromium.webrtc/master_source_cfg.py | Python | bsd-3-clause | 649 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import *
from sqlalchemy.util import *
from sqlalchemy.exc import *
from migrate.exceptions import *
from migrate.changeset import *
from migrate.tests import fixture
class CommonTestConstraint(fixture.DB):
"""helper functions to test constraints.
... | VasuAgrawal/tartanHacks2015 | site/flask/lib/python2.7/site-packages/migrate/tests/changeset/test_constraint.py | Python | mit | 10,907 |
from util import get_blob
from util import true, false
LISTENER_BLOB = {
"address": "tcp://0.0.0.0:9300",
"ssl_context": {
"alpn_protocols": "h2,http/1.1",
"cert_chain_file": "/etc/cert.pem",
"private_key_file": "/etc/key.pem"
},
"use_proxy_proto": true,
"filters": []
}
de... | lizan/envoy | test/common/json/config_schemas_test_data/test_listener_schema.py | Python | apache-2.0 | 470 |
#!/usr/bin/env python
import os
from setuptools import setup, find_packages
README = os.path.join(os.getcwd(), "README.rst")
with open(README) as f:
_LONG_DESCRIPTION= f.read()
setup(
name='tfcoreml',
version='2.0',
description='TensorFlow to Core ML converter',
long_description=_LONG_DESCRIPTIO... | tf-coreml/tf-coreml | setup.py | Python | apache-2.0 | 2,065 |
import os
import sys
import random
import pygame
from Engine import *
from Montag import *
from Character import Character
from pygame.locals import *
class AICharacter(Character):
def __init__(self, screen, **kwargs):
super().__init__(screen, **kwargs)
self.enemy = kwargs.get("enemy", None)
... | lumidify/fahrenheit451 | AICharacter.py | Python | gpl-2.0 | 3,797 |
import unittest
import logging
import sys
import datetime
from decimal import Decimal
from tigershark.facade import f835
from tigershark.parsers import M835_4010_X091_A1
class TestParsed835(unittest.TestCase):
def setUp(self):
m = M835_4010_X091_A1.parsed_835
with open('tests/835-example.txt') a... | sbuss/TigerShark | tests/test_835.py | Python | bsd-3-clause | 11,876 |
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
#... | sid88in/incubator-airflow | tests/contrib/operators/test_emr_add_steps_operator.py | Python | apache-2.0 | 3,522 |
import os
import pandas as pd
from gspread_pandas import Spread, Client
project_md_path = f"{os.getcwd()}/_posts/2012/2012-01-01-projects.md"
def get_df_from_gsheets(
folder_name: str, workbook_name: str, worksheet_name: str, cols_to_preserve=[]
) -> pd.DataFrame:
client = Client()
sheets = client.find_s... | Ladvien/ladvien.github.io | admin_build_projects_list.py | Python | mit | 1,313 |
from core.models.volume import Volume
from rest_framework import serializers
from .cleaned_identity_serializer import CleanedIdentitySerializer
from .projects_field import ProjectsField
from .get_context_user import get_context_user
class VolumeSerializer(serializers.ModelSerializer):
status = serializers.CharFie... | CCI-MOC/GUI-Backend | api/v1/serializers/volume_serializer.py | Python | apache-2.0 | 1,289 |
from django.conf.urls import include, url, patterns
from . import views_ingredient, views_recipe
urlpatterns = [
url(r'^ingredient$', views_ingredient.list_ingredient, name='listar_ingredient'),
url(r'^ingredient/save$', views_ingredient.save_ingredient, name='save_ingredient'),
url(r'^ingredient/delete$'... | lucasgr7/silverplate | objetos/urls.py | Python | mit | 783 |
""""""
from __future__ import annotations
from flask import Flask
from .criterion import TagCriterion
from .extension import TagsExtension
__all__ = ["TagsExtension", "TagCriterion"]
def register_plugin(app: Flask):
TagsExtension(app)
| abilian/abilian-core | src/abilian/web/tags/__init__.py | Python | lgpl-2.1 | 244 |
#!/usr/bin/env python
##
# Copyright (c) 2006-2015 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | red-hood/calendarserver | calendarserver/tools/anonymize.py | Python | apache-2.0 | 21,528 |
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import inspect
from models import Base, Restaurant, MenuItem, User
# Init database session
def db_init():
engine = create_engine('sqlite:///restaurantmenuwithusers.db')
Base.metadata.bind = engine
DBSession = sess... | jonanone/APIProject | vagrant/restaurant_menu/database_helper.py | Python | mit | 5,732 |
import luigi
from subprocess import call
class InputTask0(luigi.Task):
def output(self): return [luigi.LocalTarget('skills')]
class OutputTask0(luigi.Task):
def requires(self): return [InputTask0()]
def run(self): call(' grep -v BAD skills > skills.filtered;', shell=True)
def output(self... | jhorey/koopa | examples/luigi/people-skills/luigi_script.py | Python | apache-2.0 | 1,624 |
import tornado.web
from tornado.options import options
class CaptureHandler(tornado.web.RequestHandler):
def get(self):
self.render('capture.html',
address=options.address,
public_address=options.public_address)
| AlexPereverzyev/html5stream | html5stream/handlers/capture_handler.py | Python | mit | 268 |
#!/usr/bin/env python
import os
import sys
import glob
from debian import deb822
from xml.dom.minidom import Document
from dateutil.parser import parse as date_parse
def main(basedir):
e = []
error = False
num = 0
doc = Document()
events = doc.createElement('data')
doc.appendChild(events)
... | phls/eventos-brasil-timeline | build.py | Python | gpl-3.0 | 2,885 |
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not... | hapylestat/apputils | integration/setuptools/apputils_setup.py | Python | lgpl-3.0 | 4,089 |
#!/usr/bin/python
# coding: utf-8
from datetime import datetime
import deform
import colander
import jinja2
from deform import ValidationFailure
from deform.widget import CheckedPasswordWidget, HiddenWidget
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPForbidden
from pyramid.httpexceptio... | toway/towaymeetups | mba/views/admin/banners.py | Python | gpl-3.0 | 5,678 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from usuarios import models as usuarios
from django_autocomplete.admin import PublisherStateFilter
class TipoActividad(models.Model):
nombre = models.CharField(max_length=100)
color = models.Cha... | exildev/Piscix | actividades/models.py | Python | mit | 2,613 |
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
#... | adamhaney/airflow | tests/operators/test_python_operator.py | Python | apache-2.0 | 15,268 |
import os
import sys
import numpy as np
import scipy.io as sio
class DataSet(object):
def __init__(self, X, y):
self._data = X
self._labels = y
self._epochs_completed = 0
self._index_in_epoch = 0
self._num_examples = self._data.shape[0]
@property
def data(self):... | Musicophilia/nga_hacks | flask/src/data_loader.py | Python | mit | 1,839 |
"""Utility functions to parse/create OpenFlow messages."""
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2015 Brad Cowie, Christopher Lorier and Joe Stringer.
# Copyright (C) 2015 Research and Education Advanced Network New Zealand Ltd.
# Copyright (C) 2015--2019 The Contributors
#
#... | trungdtbk/faucet | faucet/valve_of.py | Python | apache-2.0 | 37,170 |
"""A generic command interpreter with multicommand support.
The cmdshell library has been initially developped to correctly handle
PhpSploit framework's shell interfaces. That being said, it was built
in order to stand generic, and usable by any other open-source project.
It extends the pretty good 'cmd' library, add... | nil0x42/shnake | shnake/shell.py | Python | gpl-3.0 | 16,792 |
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^people/$', views.people, name='survey_people'),
url(r'^people/add/$', views.people_add, name='survey_people_add'),
url(r'^people/edit/$', views.people_edit, name='survey_people_edit'),
url(r'^people/remove/$', views.people_rem... | hrpt-se/hrpt | apps/survey/urls.py | Python | agpl-3.0 | 519 |
from allauth.socialaccount.providers.oauth2.urls import default_urlpatterns
from .provider import GiteaProvider
urlpatterns = default_urlpatterns(GiteaProvider)
| pennersr/django-allauth | allauth/socialaccount/providers/gitea/urls.py | Python | mit | 164 |
# -*- coding: utf-8 -*-
import sys
from .parser import load, load_fp, load_module
__version__ = "0.4.1"
__python__ = sys.version_info
__all__ = ["load", "load_module", "load_fp", "fbs"]
| adsharma/flattools | fbs/__init__.py | Python | mit | 189 |
# encoding: utf-8
# module PyKDE4.kdecore
# from /usr/lib/python2.7/dist-packages/PyKDE4/kdecore.so
# by generator 1.135
# no doc
# imports
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtNetwork as __PyQt4_QtNetwork
class KLibrary(__PyQt4_QtCore.QLibrary):
# no doc
def factory(self, *args, **kwargs): #... | ProfessorX/Config | .PyCharm30/system/python_stubs/-1247972723/PyKDE4/kdecore/KLibrary.py | Python | gpl-2.0 | 600 |
#!/usr/bin/env python
import argparse
import json
import logging
import os
import eutils
logging.basicConfig(level=logging.INFO)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='ESummary', epilog='')
parser.add_argument('db', help='Database to use')
parser.add_argument('--user_... | nekrut/tools-iuc | tools/ncbi_entrez_eutils/esummary.py | Python | mit | 4,234 |
#######################################################################
#
# An example of creating of a Pareto chart with Python and XlsxWriter.
#
# Copyright 2013-2015, John McNamara, jmcnamara@cpan.org
#
import xlsxwriter
workbook = xlsxwriter.Workbook('chart_pareto.xlsx')
worksheet = workbook.add_worksheet()
# For... | lewislone/mStocks | packets-analysis/lib/XlsxWriter-0.7.3/examples/chart_pareto.py | Python | mit | 2,128 |
# -*- coding: utf-8 -*-
#
# This file is part of breezedb - https://github.com/RMed/breezedb_python
#
# Copyright (C) 2013-2014 Rafael Medina García <rafamedgar@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by t... | rmed/breezedb_python | breezedb/table.py | Python | gpl-2.0 | 9,362 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-07 23:02
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', ... | PreppyLLC-opensource/django-advanced-filters | advanced_filters/migrations/0001_initial.py | Python | mit | 1,420 |
from django.contrib import admin
from django.contrib.contenttypes import admin as ctadmin
# Register your models here.
from . import models
admin.site.register(models.ContainerType)
class ObjectContainerRelationAdmin(admin.ModelAdmin):
save_as=True
admin.site.register(models.ObjectContainerRelation,ObjectConta... | chiara-paci/baskerville | baskervilleweb/warehouse/admin.py | Python | gpl-3.0 | 673 |
# Copyright (c) 2013-2017 Christian Geier et al.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, ... | hobarrera/khal | khal/exceptions.py | Python | mit | 1,446 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Enquiry',
fields=[
('id', models.AutoField(auto... | pkimber/enquiry | enquiry/migrations/0001_initial.py | Python | apache-2.0 | 1,028 |
# Copyright 2011 Justin Santa Barbara
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | rakeshmi/cinder | cinder/tests/unit/integrated/test_volumes.py | Python | apache-2.0 | 7,324 |
"""
POKUS
October 2016
Magic Wand Productions
"""
try:
from colorama import *
except ImportError:
from install import install
install("colorama")
init()
from klasser import *
from random import randint
from grafikk import *
impor... | nikolhm/Pokus | pokus.py | Python | mit | 3,817 |
# -*- coding: utf-8
#!/usr/bin/env python
import os
import sys
import re
import time
import datetime
import platform
import base64, pickle
import json
import urllib2
import requests
import subprocess
AGENT_VERSION = "0.1"
SECRET = "588-R2G9-13809"
API_SERVER = "127.0.0.1:5000"
HWADDR = subprocess.Popen(["ifconfig"... | mecirt/cloudly | agent.py | Python | mit | 8,349 |
import sys
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
message = ' '.join(sys.argv[1:]) or "WorkPack..."
channel.basic_publish(exchange='',
routing_key='task_queue',
... | MartinHvidberg/jobman | rabbit_fun/ex2_newtask.py | Python | gpl-3.0 | 545 |
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib.sites.requests import RequestSite
from django.contrib.auth.decorators import login_required
from django.views.decorators.vary import vary_on_cookie
from django.views.decorators.cache impo... | gpodder/mygpo | mygpo/share/views.py | Python | agpl-3.0 | 4,078 |
import sys
sys.path.insert(1, '..')
import __builtin__
import numpy as np
import pandas as pd
import networkx as nx
from MarkovChain import *
from MarkovChain.node_objectives import *
PLOTS_DATA_DIR = "/home/grad3/harshal/Desktop/MCMonitor/Plots_data/"
num_nodes = 1000
num_items = num_nodes
item_distributions = ['un... | chdhr-harshal/MCMonitor | src/python/experiments/time_variance_plot.py | Python | mit | 2,342 |
import random
import numpy
class DiffusionModel:
def __init__(self, n, m, ep, p, q):
self.G = self.__init_graph(n, ep)
self.infect_prob = p
self.false_neg_prob = q
self.infected = set()
while len(self.infected) < m:
x = random.randrange(n)
if x not in... | wctaiwan/pomcp-diffusion | diffusion_model.py | Python | bsd-2-clause | 3,958 |
# Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | FrankDuan/df_code | dragonflow/tests/unit/test_redis_db.py | Python | apache-2.0 | 3,638 |
import sys
class Logger(object):
"""
Copypasta from stackoverflow forums.
All credit to users Amith Koujalgi and Eric Leschinsky
http://stackoverflow.com/questions/14906764/
Writes all stdout to file as well as printing to stdout
Initialize with sys.stdout = Logger()
"""
def __init__(self, fname):
self.te... | pachterlab/sircel | sircel/utils/Logger.py | Python | mit | 843 |
#!/usr/bin/env python
from sys import stderr
import re
from sed.engine import (
StreamEditor,
call_main,
ACCEPT, REJECT, NEXT, REPEAT,
ANY
)
FN_DECL_FMT = re.compile(r'''
^
\s*
def\s+test.+
$
''', re.VERBOSE)
DOCSTRING_FMT = re.compile(r'''
^
(?P<indent>\s*)
"""
(?P<c... | hughdbrown/sed-apps | src/javascript/sed_docstrings.py | Python | mit | 2,544 |
import re
import operator
from core.errors import InputError
def create_words_dictionary(input_list):
words_dictionary = []
for line in input_list:
word, freq = line.split()
if len(word) > 15:
raise "Bad input. %s is longer than 15 letters!" % word
if word not in words_di... | W84TheSun/user_input_prompt_task | net_task/core/common_functions.py | Python | mit | 1,112 |
from django.db import models
from django.contrib.auth.models import User
class Record(models.Model):
id = models.AutoField(primary_key=True)
owner = models.ForeignKey(User)
create_time = models.DateTimeField()
keyword = models.CharField(max_length=16)
last_lookup_time = models.DateTimeField()
... | elliott-wen/Dictionary-Django | dictionary/models.py | Python | apache-2.0 | 398 |
from django.conf import settings
from django.contrib.sites.models import RequestSite
from django.contrib.sites.models import Site
from registration import signals
from voodoo.mainsite.forms import UserRegistrationForm
from voodoo.mainsite.models import MyRegistrationProfile
# from registration.models import Registrati... | Smiter/voodoo | voodoo/mainsite/RegistrationBackend/__init__.py | Python | gpl-2.0 | 5,781 |
# https://github.com/UCB-ICSI-Vision-Group/decaf-release/wiki/imagenet
import os, sys
from utils import tic, toc
import numpy as np
import time
##################################
# Parameter checking
#################################
if len(sys.argv) < 3:
print 'Use: extractCNNFeatures.py bboxes imgsDir outputFile'
... | jccaicedo/localization-agent | learn/cnn/extractCNNFeaturesOnRegions2.py | Python | mit | 4,001 |
# Copyright 2015-2016 Internap.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | stephanerobert/fake-switches | fake_switches/switch_configuration.py | Python | apache-2.0 | 8,231 |
from django.test import TestCase
from phonenumber_field.modelfields import PhoneNumberField
from whats_fresh.whats_fresh_api.models import Vendor
from django.contrib.gis.db import models
class VendorTestCase(TestCase):
def setUp(self):
self.expected_fields = {
'name': models.TextField,
... | iCHAIT/whats-fresh-api | whats_fresh/whats_fresh_api/tests/models/test_vendor_model.py | Python | apache-2.0 | 2,632 |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes ... | AutorestCI/azure-sdk-for-python | azure-mgmt-network/azure/mgmt/network/v2015_06_15/models/network_management_client_enums.py | Python | mit | 3,928 |
# -*- coding: utf-8 -*-
import io
from nose.tools import assert_equal, assert_in, assert_not_in, \
assert_true, assert_false
from submitter.asset import Asset, AssetSet
from submitter.envelope import Envelope, EnvelopeSet
class TestEnvelope():
def test_construct(self):
data = io.StringIO('''{
... | deconst/submitter | test/envelope_test.py | Python | apache-2.0 | 5,199 |
# -*- coding: utf-8 -*-
#
# MuG DMP API documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 23 13:47:59 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#... | Multiscale-Genomics/mg-dm-api | docs/conf.py | Python | apache-2.0 | 10,292 |
from sympy import *
def test_floor():
x = Symbol('x')
y = Symbol('y', real=True)
k, n = symbols('kn', integer=True)
assert floor(nan) == nan
assert floor(oo) == oo
assert floor(-oo) == -oo
assert floor(0) == 0
assert floor(1) == 1
assert floor(-1) == -1
assert floor(E) ==... | certik/sympy-oldcore | sympy/functions/elementary/tests/test_integers.py | Python | bsd-3-clause | 3,942 |
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | GoogleCloudPlatform/python-compat-runtime | appengine-compat/exported_appengine_sdk/google/appengine/ext/vmruntime/middlewares.py | Python | apache-2.0 | 10,700 |
# -*- coding: utf-8 -*-
"""
brickv (Brick Viewer)
Copyright (C) 2011 Olaf Lüke <olaf@tinkerforge.com>
__init__.py: package initialization
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either versi... | Tinkerforge/brickv | src/brickv/plugin_system/plugins/dc/__init__.py | Python | gpl-2.0 | 892 |
from setuptools import setup
setup(name='raumfeld',
version='0.5',
install_requires='mock',
packages=['raumfeld'],
) | maierp/PyRaumfeld | setup.py | Python | mit | 129 |
# -*- coding: utf-8 -*-
import httplib, urllib
from django.db import models
from django.conf import settings
class VoiceNotifier(object):
_host = settings.VOICE_NOTIFIER_HOST
_port = settings.VOICE_NOTIFIER_PORT
_service = settings.VOICE_NOTIFIER_SERVICE
_text = "Поступило новое желание"
def notify(self, text... | 2gis/wishpush | notifier/models.py | Python | mit | 2,030 |
# -*- coding: utf-8 -*-
import time
from django.urls import reverse
from django.db import models
from django.template.defaultfilters import truncatechars
from django.utils.text import slugify
from django.utils import timezone
from django.conf import settings
from markupfield.fields import MarkupField
from model_utils... | WimpyAnalytics/django-andablog | andablog/models.py | Python | bsd-2-clause | 3,341 |
import time
from thrift.TSerialization import serialize, deserialize
from thrift.protocol.TBinaryProtocol import (
TBinaryProtocolFactory,
TBinaryProtocolAcceleratedFactory
)
from addressbook import ttypes
def make_addressbook():
phone1 = ttypes.PhoneNumber()
phone1.type = ttypes.PhoneType.MOBILE
... | importcjj/thriftpy | benchmark/benchmark_apache_thrift_struct.py | Python | mit | 1,554 |
# ID-Fits
# Copyright (c) 2015 Institut National de l'Audiovisuel, INA, All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, ... | ina-foss/ID-Fits | lib/filtering.py | Python | lgpl-3.0 | 1,464 |
#!/usr/bin/python
#
# Copyright (c) 2017 Zim Kalinowski, <zikalino@microsoft.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
... | tersmitten/ansible | lib/ansible/modules/cloud/azure/azure_rm_containerinstance_facts.py | Python | gpl-3.0 | 10,883 |
from __future__ import absolute_import
import unittest
import json
from xblock.field_data import DictFieldData
from mock import Mock
from poll.poll import PollBlock, SurveyBlock
from ..utils import MockRuntime, make_request
class TestPollBlock(unittest.TestCase):
"""
Tests for XBlock Poll.
"""
def s... | msaqib52/xblock-poll | tests/unit/test_xblock_poll.py | Python | agpl-3.0 | 9,790 |
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
#
# MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without lim... | gangadhar-kadam/mtn-wnframework | webnotes/tests/test_patch.py | Python | mit | 2,628 |
# -*- coding: utf-8 -*-
"""
Local settings
- Run in Debug mode
- Use console backend for emails
- Add Django Debug Toolbar
- Add django-extensions as app
- Add django-spaghetti-and-meatballs as app
"""
from django.utils.translation import ugettext_lazy as _
from .common import * # noqa
print("DEBUG: Loading settings... | marshalc/guerdon | config/settings/development.py | Python | gpl-2.0 | 2,585 |
# -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apach... | heiths/allura | ForgeGit/forgegit/tests/__init__.py | Python | apache-2.0 | 1,048 |
#!/usr/bin/env python
# Merges helper scripts into bakefile.m4
#
# $Id: merge-scripts.py 988 2007-01-11 00:00:03Z vaclavslavik $
MARK_IDENT = 'dnl ===================== '
MARK_BEGINS = ' begins here ====================='
MARK_ENDS = ' ends here ====================='
import re
def mergeFile(filename):
f = open... | aponxi/libmysqlpp | bakefile-0.2.9/autoconf/merge-scripts.py | Python | lgpl-2.1 | 1,652 |
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 9 09:52:05 2016
@author: katerinailiakopoulou
"""
import logging
import string
from gensim.models import Word2Vec
from gensim.models.phrases import Phrases
import sys
import re
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)... | matzika/article-tagger-system | word2vec_builder.py | Python | gpl-2.0 | 3,091 |
""" Module for unpacking of events data. Handles bits
in order to increase processing speed to maximum.
"""
import struct
VALID_MARK_SHIFT = 0
VALID_MARK_MASK = 0x00000001
POLARITY_SHIFT = 1
POLARITY_MASK = 0x00000001
Y_ADDR_SHIFT = 2
Y_ADDR_MASK = 0x00007FFF
X_ADDR_SHIFT = 17
X_ADDR_MASK = 0x00007FFF
def _get_pola... | orpinchasov/pycaer | pycaer/dvs128/process_packets.py | Python | gpl-3.0 | 731 |
import tests.model_control.test_ozone_custom_models_enabled as testmod
testmod.build_model( ['None'] , ['MovingMedian'] , ['Seasonal_Hour'] , ['SVR'] ); | antoinecarme/pyaf | tests/model_control/detailed/transf_None/model_control_one_enabled_None_MovingMedian_Seasonal_Hour_SVR.py | Python | bsd-3-clause | 154 |
from .filter import LogDedicatedLevelFilter
| SpeedProg/eve-inc-waitlist | waitlist/utility/logging/__init__.py | Python | mit | 44 |
import os
from flask import Blueprint
from flask.ext.admin import Admin
from .views import (CommentAdmin, PostAdmin, ProjectAdmin, SecureIndexView,
SecureFileAdmin, TagAdmin, UserAdmin)
from config import basedir
admin = Blueprint('admin_page', __name__)
def create_admin(app, session):
'''... | ColeKettler/site | app/admin/__init__.py | Python | mit | 1,016 |
try:
# Check if the basestring type if available, this will fail in python3
basestring
except NameError:
basestring = str
class ControlFileParams:
generalParams = "GeneralParams"
spawningBlockname = "SpawningParams"
simulationBlockname = "SimulationParams"
clusteringBlockname = "clustering... | AdaptivePELE/AdaptivePELE | AdaptivePELE/validator/validatorBlockNames.py | Python | mit | 8,469 |
"""This module is a wrapper around json methods for (de)serializing
two predefined objects: Request and Response. They are intended to be
used for calls between threads.
Named tuple objects:
Request -- contains two parameters, 'method' and 'params'
Response -- contains one parameter, 'result'
Functions:
deserialize ... | brisad/kaimu | serialization.py | Python | gpl-3.0 | 1,109 |
#! /bin/python3/
"""
Author: @pme1123
Created: Jan 17th, 2017
Frangi Segmentation - combines various functions into a single one for convenience
Frangi Image Loop - For series analysis across directories.
"""
import os
import pandas as pd
from pyroots import *
from skimage import io, color, filters, morphology, im... | pme1123/pyroots | pyroots/frangi_segmentation.py | Python | apache-2.0 | 12,341 |
# -*- coding: utf-8 -*-
# Specto , Unobtrusive event notifier
#
# import_export.py
#
# See the AUTHORS file for copyright ownership information
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Founda... | Pi03k/py3specto | spectlib/export_watch.py | Python | gpl-2.0 | 7,911 |
'''
https://leetcode.com/contest/weekly-contest-161/problems/minimum-remove-to-make-valid-parentheses/
'''
class Solution:
def minRemoveToMakeValid(self, s: str) -> str:
n = len(s)
stk = []
for i, c in enumerate(s):
if c not in '()': continue
if len(stk) > 0 and s[stk... | jan25/code_sorted | leetcode/weekly161/3_parens.py | Python | unlicense | 484 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# tifffile.py
# Copyright (c) 2008-2014, Christoph Gohlke
# Copyright (c) 2008-2014, The Regents of the University of California
# Produced at the Laboratory for Fluorescence Dynamics
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or wit... | jzaremba/sima | sima/misc/tifffile.py | Python | gpl-2.0 | 145,890 |
# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
# In[2]:
train_df = pd.read_csv('./input/train.csv', index_col=0)
test_df = pd.read_csv('./input/test.csv', index_col=0)
# In[4]:
train_df.head()
# In[6]:
#label本身并不平滑。为了我们分类器的学习更加准确,我们会首先把label给“平滑化”(正态化)
import matplotlib.pyplot as plt
pr... | muxiaobai/CourseExercises | python/kaggle/competition/house-price/house.py | Python | gpl-2.0 | 4,162 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# mo... | jodogne/OrthancMirror | OrthancServer/Resources/Samples/Python/DownloadAnonymized.py | Python | gpl-3.0 | 1,686 |
#!python2
import logging
import os
from datetime import datetime
FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
logging.basicConfig(format=FORMAT, level=logging.INFO)
log = logging
from flask import Flask, render_template, request, jsonify
from bson.objectid import ObjectId
from models.url_model import URLModel
... | CooperLuan/note-you-like | nyl.py | Python | mit | 1,840 |
__author__ = 'Lenusik'
from model.group import Group
from timeit import timeit
def test_group_list(app, db):
print(timeit(lambda: app.group.get_group_list(), number=1))
def clean(group):
return Group(id=group.id, name=group.name.strip())
print(timeit(lambda: map(clean, db.get_group_list()), number=... | Lenusik/python | test/test_db_matches_ui.py | Python | gpl-2.0 | 451 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2021-06-23 10:56
from __future__ import unicode_literals
import astrobin_apps_equipment.models.equipment_item
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
... | astrobin/astrobin | astrobin_apps_equipment/migrations/0005_add_sensor_and_camera.py | Python | agpl-3.0 | 4,735 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.