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 re
from django.utils.encoding import force_str
from django.utils.timezone import get_current_timezone_name
def find_placeholder_relation(obj):
return 'page'
class classproperty:
"""Like @property, but for classes, not just instances.
Example usage:
>>> from cms.utils.helpers import cla... | rsalmaso/django-cms | cms/utils/helpers.py | Python | bsd-3-clause | 2,493 |
"""
See WorldMap model dataverse_info.models.DataverseInfo
https://github.com/cga-harvard/cga-worldmap/blob/e8554beda280aefc02e0b75d10613272a4ca2786/src/GeoNodePy/geonode/dataverse_info/models.py
Translate the GISDataFile object into a dict that can be passed to the DataverseInfoValidationForm*
* https://githu... | IQSS/geoconnect | gc_apps/gis_basic_file/dataverse_info_service.py | Python | apache-2.0 | 1,405 |
#
# GNU Mailutils -- a suite of utilities for electronic mail
# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
#
# 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
# ve... | ssvlab/esbmc-gpu | regression/esbmc-cpp/projects/mailutils-2.2/python/mailutils/message.py | Python | apache-2.0 | 5,009 |
# Copyright (c) 2015 Red Hat, 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 or ... | waltBB/neutron_read | neutron/agent/ovsdb/native/connection.py | Python | apache-2.0 | 2,788 |
#!/usr/bin/env python
__author__ = 'tinko minko'
| kinimesi/rscore | __init__.py | Python | apache-2.0 | 49 |
## Copyright (c) 2012-2015 Aldebaran Robotics. All rights reserved.
## Use of this source code is governed by a BSD-style license that can be
## found in the COPYING file.
from qisys import ui
import time
import qitest.test_queue
import qitest.runner
import qitest.result
class DummyLauncher(qitest.runner.TestLauncher)... | dmerejkowsky/qibuild | python/qitest/test/test_queue.py | Python | bsd-3-clause | 2,465 |
#!/usr/bin/python
import sys,socket
from thread import start_new_thread
HOST = 'localhost'
PORT = 9001
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.bind((HOST, PORT))
except socket.error, msg:
print 'Bind Failed. Error code : ' + str(msg[0]) + ' message ' + msg[1]
sys.exit()
print 'Socket bindi... | tuxfux-hlp-notes/python-batches | archieves/batch-64/18-sockets-tuxfux/HClive_server.py | Python | gpl-3.0 | 780 |
import unittest
from nose.tools import (assert_false, assert_raises, assert_true,
assert_equal, assert_in)
import io
import pickle
import numpy
import logging
from sklearn.base import clone
import sknn
from sknn.mlp import Regressor as MLPR
from sknn.mlp import Layer as L, Convolution as C
f... | jgdwyer/ML-convection | sknn_jgd/tests/test_deep.py | Python | apache-2.0 | 4,582 |
#!/usr/bin/python
#
# Copyright 2019 Google LLC
#
# 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 ag... | google/sqlcommenter | python/sqlcommenter-python/tests/generic/test_opencensus.py | Python | apache-2.0 | 1,434 |
#timer.py
import os
from numpy import fromfile,float32
class data:
def __init__(self,path='build'):
data={}
files=[e for e in os.listdir(path) if 'timer' in e]
def tokey(name):
try:
return os.path.splitext(name)[0].split('-')[1]
except:
return None
for fname,key in zip(fil... | TeravoxelTwoPhotonTomography/fetch | timer.py | Python | bsd-3-clause | 734 |
#!/usr/bin/env python
"""
Copyright 2014 Jirafe, 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 la... | concerned3rdparty/jirafe-python | jirafe/CategoryApi.py | Python | mit | 2,134 |
from asynctnt_queue import Queue, Tube
from tests import BaseTarantoolTestCase
class QueueTestCase(BaseTarantoolTestCase):
async def test__queue_create(self):
q = Queue(self.conn)
self.assertEqual(q.conn, self.conn, 'conn valid')
def test__queue_get_tube(self):
q = Queue(self.conn)
... | igorcoding/asynctnt-queue | tests/test_queue.py | Python | apache-2.0 | 925 |
# -*- coding: utf-8 -*-
"""
odict
~~~~~
This module is an example implementation of an ordered dict for the
collections module. It's not written for performance (it actually
performs pretty bad) but to show how the API works.
Questions and Answers
=====================
Why would any... | tlangerak/Multi-Agent-Systems | spade/odict.py | Python | lgpl-2.1 | 10,695 |
#!/usr/bin/env python
from fabric.api import env,run,cd,put,local
import fabric.colors
import os
env.color_settings = {
'abort': yellow,
'error': yellow,
'finish': cyan,
'host_prefix': green,
'prefix': red,
'prompt': blue,
'task': red,
'warn': yellow
}
env.roledefs = {
'adr_ct': [... | guadeitong/script | common/fabfile.py | Python | cc0-1.0 | 1,454 |
import os
import json
from django.test import TestCase
from documents.models import Document
from documents.exporters.sql import (MysqlExporter, OracleExporter,
PostgresExporter, SQLiteExporter)
TEST_DOCUMENT_PATH = os.path.join(os.path.dirname(__file__),
... | fatiherikli/dbpatterns | web/dbpatterns/documents/tests.py | Python | mit | 3,562 |
import sys, unittest, re, os.path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'src'))
from Exscript import PrivateKey
class PrivateKeyTest(unittest.TestCase):
CORRELATE = PrivateKey
def setUp(self):
self.filename = 'my.key'
self.password = 'test1'
self.key ... | gnperumal/exscript | tests/Exscript/PrivateKeyTest.py | Python | gpl-2.0 | 1,746 |
# -*- coding: UTF-8 -*-
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Canonical Ltd.
# Copyright (C) 2006 Gustavo Franco
#
# This file is part of Germinate.
#
# Germinate is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
... | aurex-linux/germinate | germinate/scripts/germinate_update_metapackage.py | Python | gpl-2.0 | 17,950 |
# -*- coding: utf-8 -*-
#
# box_management documentation build configuration file, created by
# sphinx-quickstart.
#
# 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.
#
# All configuration values... | waveFrontSet/box_management | docs/conf.py | Python | mit | 7,947 |
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either... | VirtualRaven/mathlibra | wrapper/c_api_interface/.ycm_extra_conf.py | Python | mpl-2.0 | 6,147 |
# -*- coding: utf-8 -*-
from AppTEA.views import *
"""
Vista del Administrador para gestionar las áreas existentes.
"""
@login_required(login_url="/loguearse")
def areas(request):
# Si es Administrador
if request.user.is_staff:
if (request.method == "POST"):
filtro = request.POST['filtro... | nico4021/RegistroTEA | ProyectoTEA/AppTEA/views/area.py | Python | gpl-2.0 | 2,960 |
# -*- coding: utf-8 -*-
from sqlalchemy import (
Column, DateTime, ForeignKey, Integer, Sequence, String, Table,
UniqueConstraint, Float, Boolean
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref
from .db import session, engine
from .utils import hash_p... | mikejarrett/company-time-clock | timeclock/logic/models.py | Python | mit | 3,309 |
# This is a work in progress, MVP implementation. Please do not assume it is secure, because it is not in pretty much literally every way imaginable.
# DO NOT DEPLOY THIS UNTIL IT HAS BEEN FIXED.
# The complete implementation will be based on 858 code, but will need to be modified to support SSO based on MIT certs.
#
#... | simmons-tech/api | src/utils/authorization_core/authorization_core.py | Python | lgpl-3.0 | 8,643 |
# https://projecteuler.net/problem=22
from projecteuler.FileReader import file_to_split_string_array
import string
names = file_to_split_string_array("p022.txt")
names.sort()
score = 0
for i in range(len(names)):
score += (i + 1) * sum([string.ascii_uppercase.index(c) + 1 for c in names[i]])
print(score)
| Peter-Lavigne/Project-Euler | p022.py | Python | mit | 315 |
# coding: utf-8
"""
Copyright 2015 SmartBear Software
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 applica... | jlongever/redfish-client-python | on_http_redfish_1_0/models/rack_hd_boot_image_boot_image_list.py | Python | apache-2.0 | 4,038 |
"""
STARBURST LabJack Control Wrapper Library
Author: Lokbondo Kung
Email: lkkung@caltech.edu
"""
from labjack import ljm
import time
import copy
import math
"""
Class: UnknownDeviceError extends Exception
Description:
Custom error for handling in upper wrapper. Takes the LJMError
fr... | lokokung/Starburst-LabJack-OVRO | sblj/sblj.py | Python | mit | 27,843 |
def spiral_corners(size):
yield 1
for x in range(3, size+1, 2):
base_corner = x**2
corner_diff = x-1
for corner in (3,2,1,0):
yield base_corner-corner_diff*corner
def solve_p026():
return sum(spiral_corners(1001))
if __name__ == '__main__':
print(solve_p026())
| piohhmy/euler | p028.py | Python | mit | 315 |
#---------------------------------------------------------------------------
# Copyright 2013 The Open Source Electronic Health Record Agent
#
# 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
#
... | josephsnyder/VistA | Packages/Kernel/Testing/RAS/UTZTMGRSET.py | Python | apache-2.0 | 5,082 |
# Copyright (c) 2015 Microsoft Corporation
from z3 import *
set_option(auto_config=True)
p = Bool('p')
q = Bool('q')
print And(p, q, True)
print simplify(And(p, q, True))
print simplify(And(p, False))
| dstaple/z3test | old-regressions/python/z3py.8.py | Python | mit | 203 |
# This file is part of Fido
# Copyright (C) 2015 Simone 'evilsocket' Margaritelli
# evilsocket@gmail.com
# https://evilsocket.net
#
# 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 versio... | evilsocket/fido | fido/templates/make_c.py | Python | gpl-3.0 | 1,136 |
import sys
from argparse import ArgumentParser
from borgmatic.config import generate, validate
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'
def parse_arguments(*arguments):
'''
Given command-line arguments with which this script was invoked, parse the arguments and return
them as a... | witten/borgmatic | borgmatic/commands/generate_config.py | Python | gpl-3.0 | 2,101 |
import pygame
from pygame.locals import *
class Food(pygame.sprite.Sprite):
def __init__(self, tile, x, y):
super(Food, self).__init__()
self.tile = tile
self.energy = 1000
w = self.w = 9
h = self.h = 5
self.image = pygame.Surface((w, h), SRCALPHA).convert_alpha()... | flexo/evolutron | evolutron/food.py | Python | mit | 1,376 |
"""
Completer for a regular grammar.
"""
from __future__ import unicode_literals
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.document import Document
from .compiler import _CompiledGrammar
__all__ = [
'GrammarCompleter',
]
class GrammarCompleter(Completer):
"""
Compl... | lmregus/Portfolio | python/design_patterns/env/lib/python3.7/site-packages/prompt_toolkit/contrib/regular_languages/completion.py | Python | mit | 2,975 |
# ==============================================================================
# Copyright 2019 - Philip Paquette
#
# NOTICE: 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 rest... | diplomacy/research | diplomacy_research/models/datasets/feedable_dataset.py | Python | mit | 5,758 |
#!/usr/bin/python
# Copyright 2014 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Tests the cxxflags feature
import BoostBuild
t = BoostBuild.Tester(use_test_config=False)
# cxxflags should b... | nawawi/poedit | deps/boost/tools/build/test/feature_cxxflags.py | Python | mit | 786 |
from .middlewares import toolbar_middleware_factory, middleware
from .main import setup, APP_KEY
__version__ = '0.3.0'
__all__ = ['setup', 'middleware', 'toolbar_middleware_factory', 'APP_KEY']
| realer01/aiohttp-debugtoolbar | aiohttp_debugtoolbar/__init__.py | Python | apache-2.0 | 196 |
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
import re
import string
import urllib.parse
from typing import List, Optional as TOptional, Set
from pkg_resources.extern.pyparsing import... | martbhell/wasthereannhlgamelastnight | src/lib/pkg_resources/_vendor/packaging/requirements.py | Python | mit | 4,706 |
# -*- coding:utf-8 -*-
from .language import DEFAULT_LANG_CODE, USER_LANG
__al__ = ['trans']
I18N_MAP = {
DEFAULT_LANG_CODE:
{
"definitions" : "Definitions",
"see also" : "See also",
"synonyms" : "Synonyms",
... | luw2007/python-translate-cli | pytrans/i18n.py | Python | mit | 3,236 |
# -*- coding: utf-8 -*-
from urllib import quote_plus
from django import template
from threebot import __version__
from threebot.utils import get_my_orgs, get_preset_worker, has_admin_permission, render_template
from threebot.models import WorkflowPreset, WorkflowTask
register = template.Library()
@register.inclusi... | 3bot/3bot | threebot/templatetags/threebot_tags.py | Python | bsd-3-clause | 1,977 |
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/do... | HubSpot/django-reversion | src/test_project/urls.py | Python | bsd-3-clause | 577 |
"""User email must be unique and non-nullable
Revision ID: 56630a78dca0
Revises: ed3110b30b84
Create Date: 2017-01-25 08:46:37.652600
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '56630a78dca0'
down_revision = 'ed3110b30b84'
branch_labels = None
depends_on = ... | pbraunstein/trackercise | migrations/versions/56630a78dca0_.py | Python | mit | 944 |
from django.core import mail
from django.test import TestCase
from geokey.projects.models import Project
from geokey.projects.tests.model_factories import ProjectFactory
from geokey.categories.models import Category, TextField
from geokey.categories.tests.model_factories import (
CategoryFactory,
TextFieldFact... | ExCiteS/geokey-airquality | geokey_airquality/tests/test_models.py | Python | mit | 8,826 |
#
# Copyright (C) 2012-2014 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it wi... | atodorov/anaconda | pyanaconda/ui/gui/xkl_wrapper.py | Python | gpl-2.0 | 15,372 |
"""Update note links
Revision ID: 30421387bea5
Revises: 338772789e1f
Create Date: 2016-01-04 10:00:35.572008
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '30421387bea5'
down_revision = '338772789e1f'
def upgrade():
op.execute("""
UPDATE events.... | belokop/indico_bare | migrations/versions/201604011102_30421387bea5_update_note_links.py | Python | gpl-3.0 | 3,796 |
# @@@ START COPYRIGHT @@@
#
# 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... | apache/incubator-trafodion | install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py | Python | apache-2.0 | 8,531 |
"""
================================
Compute ICA components on epochs
================================
ICA is fit to MEG raw data.
We assume that the non-stationary EOG artifacts have already been removed.
The sources matching the ECG are automatically found and displayed.
Note that this example does quite a bit of p... | teonlamont/mne-python | examples/preprocessing/plot_run_ica.py | Python | bsd-3-clause | 1,818 |
'''
Created on Aug 21, 2014
@author: moloyc
'''
import os
import sys
sys.path.insert(0,os.path.abspath(os.path.dirname(__file__) + '/' + '../..')) #trick to make it run from CLI
import unittest
import jnpr
from jnpr.openclos.util import *
class TestFunctions(unittest.TestCase):
def setUp(self):
pass
... | yunli2004/OpenClos | jnpr/openclos/tests/unit/test_util.py | Python | apache-2.0 | 5,479 |
# Copyright 2016-2017 Rumma & Ko Ltd
# License: GNU Affero General Public License v3 (see file COPYING for details)
"""Lino's :mod:`lino.modlib.restful` plugin is an adapter to the
django-restful framework.
Usage:
- Add ``'lino.modlib.restful'`` to your :meth:`get_installed_apps`.
- Install `djangorestframework` ma... | lino-framework/lino | lino/modlib/restful/__init__.py | Python | bsd-2-clause | 1,487 |
from blackpearl.modules import Module
from blackpearl.projects import Project
from blackpearl.things import Rainbow
from blackpearl.things import Slider
class DiscoLights(Module):
listening_for = ['slider',]
hardware_required = [Slider, Rainbow,]
def receive(self, message):
# We're listening ... | offmessage/blackpearl | blackpearl/examples/discolights.py | Python | mit | 977 |
#
# 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 us... | mxm/incubator-beam | sdks/python/apache_beam/internal/gcp/json_value_test.py | Python | apache-2.0 | 3,775 |
from django.contrib import admin
from myapp.models import *
admin.site.register(Type)
admin.site.register(Type2Type)
| 1d20/INT20H | myapp/admin.py | Python | mit | 118 |
import dbus
from twisted.words.xish import domish
import constants as cs
from file_transfer_helper import exec_file_transfer_test, ReceiveFileTest
from config import FILE_TRANSFER_ENABLED
if not FILE_TRANSFER_ENABLED:
print "NOTE: built with --disable-file-transfer"
raise SystemExit(77)
class ReceiveFileAn... | Ziemin/telepathy-gabble | tests/twisted/file-transfer/test-receive-file-and-sender-disconnect-while-pending.py | Python | lgpl-2.1 | 1,458 |
#!/usr/bin/env python2
from lib.PipeTool import PipeTool
from collections import defaultdict
DESCRIPTION = """Creates a combined histogram for all lines of the
input file in the format token_0:count_0 ...token_n:count_0 """
class Histogram(PipeTool):
def __init__(self, description):
PipeTool.__init... | fabsx00/seq-tools | histogram.py | Python | gpl-3.0 | 864 |
age = raw_input("How old are you? ")
height = raw_input("How tall are you? ")
weight = raw_input("How much do you weigh? ")
print "So, you're %r old, %r tall and %r heavy." %(age, height, weight)
| afronski/playground-other | python/books/learn-python-the-hard-way/ex12.py | Python | mit | 197 |
import sys
import _midgard as midgard
import local_connection
import dbus
import midgard_dbus as mgdbus
def main():
cnc = local_connection.quick_connection()
cnc.connect("midgard")
cnc.set_loglevel("debug")
midgard.dbus.send("/midgard_article", "Hi there!");
topic = midgard.mgdschema.midgard_topic(1)
guid = t... | midgardproject/midgard-python | tests.old/dbus/midgard_client.py | Python | lgpl-2.1 | 450 |
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'PaymentTransaction.mango_account'
db.add_column('pledger_paymenttransaction', 'mango_account... | alexykot/bitfund | bitfund/pledger/migrations/0022_auto__add_field_paymenttransaction_mango_account__add_field_paymenttra.py | Python | gpl-3.0 | 28,753 |
from typing import Dict, MutableMapping, Mapping
from allennlp.data.fields.field import DataArray, Field
from allennlp.data.vocabulary import Vocabulary
from allennlp.common.util import JsonDict
class Instance(Mapping[str, Field]):
"""
An `Instance` is a collection of :class:`~allennlp.data.fields.field.Fiel... | allenai/allennlp | allennlp/data/instance.py | Python | apache-2.0 | 5,050 |
from cloudify import ctx
from cloudify.exceptions import NonRecoverableError
from cloudify.state import ctx_parameters as inputs
import subprocess
import os
import re
import sys
import time
import threading
import platform
from StringIO import StringIO
from cloudify_rest_client import CloudifyClient
from cloudify im... | alien4cloud/alien4cloud-cloudify3-provider | alien4cloud-cloudify3-provider/src/test/resources/outputs/blueprints/openstack/new_scalable_compute/wrapper/FileSystem/tosca.interfaces.node.lifecycle.Standard/create/_a4c_create.py | Python | apache-2.0 | 17,728 |
# -*- coding: UTF-8 -*-
# darkforce
# create at 2015/9/28
# autor: qianqians
import sys
sys.path.append('../')
from plask import *
from check import *
from login import *
def on_get_check(p):
num,text = random_check()
print pysession.session
csession = pysession.session[p["sid"]]
csession["login_check"] = num
ret... | theDarkForce/DarkForceHttp | loginui.py | Python | gpl-2.0 | 15,506 |
import re
import csv
import os
import pickle
import config as cfg
class CourseURL:
""" Course URL : A class for handling course URLs
- Ensures consistent formatting
- Provides methods to access unit, subunit and sequence numbers"""
# Regexp to filter out strings that are not URLs.
IS_URL = c... | EDUlib/eTracesX | Translation_software/edx_to_MOOCdb_piping/import.openedx.qpipe/helperclasses.py | Python | agpl-3.0 | 17,815 |
import logging
import numpy as np
from sklearn.cluster import KMeans
class ClusterLogging:
def __init__(self, logger=logging.Logger("logging")):
'''
By default, logger object in default configuration
'''
self.nodes={}
self.messages={}
self.nums=0
self.lo... | saromanov/clusterlogging | clusterlogging.py | Python | mit | 2,535 |
import re
class ibeon:
def remSpaces(data):
return data.replace(" ", "")
def remNumbers(data):
return ''.join([x for x in data if not x.isdigit()])
def remSymbols(data):
return re.sub('[^\w]', '', data)
def onlyNumbers(data):
return re.sub('[^0-9]', '', data)
def onlyAlp... | Aroliant/iBeon | python/ibeon.py | Python | mit | 901 |
import math, util, rotmat
from rotmat import Vector3, Matrix3
class Aircraft(object):
'''a basic aircraft class'''
def __init__(self):
self.home_latitude = 0
self.home_longitude = 0
self.home_altitude = 0
self.ground_level = 0
self.frame_height = 0.0
self.latitu... | ptsneves/QuadSim_OpenGL | aircraft.py | Python | gpl-3.0 | 1,723 |
import json
import logging
import ckan.lib.search as search
import ckan.lib.dictization.model_dictize as model_dictize
from ckanext.harvest.model import HarvestObject
from ckan.lib.base import model
from ckan.model import Session
from ckanext.multilang.model import PackageMultilang, GroupMultilang, TagMultilang
fr... | tdipisa/ckanext-multilang | ckanext/multilang/harvesters/multilang.py | Python | agpl-3.0 | 20,523 |
import pandas as pd
import csv
import os
import matplotlib.image as mpimg
from matplotlib import gridspec
from skimage import color
import numpy as np
from skimage.util import dtype
def _prepare_rgba_array(arr):
"""Check the shape of the array to be RGBA and convert it to
floating point representation.
"""... | hemagso/neuralmon | utility/load.py | Python | gpl-3.0 | 4,397 |
"""text_file
provides the TextFile class, which gives an interface to text files
that (optionally) takes care of stripping comments, ignoring blank
lines, and joining lines with backslashes."""
import sys, os, io
class TextFile:
"""Provides a file-like object that takes care of all the things you
commonl... | Microvellum/Fluid-Designer | win64-vc/2.78/python/lib/site-packages/numpy/distutils/text_file.py | Python | gpl-3.0 | 12,467 |
import unittest
import os
from PIL import Image
from django.conf import settings
from sorl.thumbnail.base import Thumbnail
try:
set
except NameError:
from sets import Set as set # For Python 2.3
def get_default_settings():
from sorl.thumbnail import defaults
def_settings = {}
for key in dir(d... | cuker/sorl-thumbnail-legacy | sorl/thumbnail/tests/base.py | Python | bsd-3-clause | 3,778 |
import os
import sys
from numpy import *
from scipy.integrate import odeint
my_path = os.path.dirname(os.path.abspath(__file__))
#sys.path.append(os.path.join(my_path, '..'))
from fds import *
dt = 0.05
def dudt(u, s):
z0 = 0
x, y, z, x0, y0 = u
dxdt = 10 * (y - x)
dydt = x * (s - z + z0) - y
d... | qiqi/fds | tests/test_lyapunov_vector.py | Python | gpl-3.0 | 1,338 |
"""Authentication for HTTP component."""
import base64
import logging
from aiohttp import hdrs
from aiohttp.web import middleware
import jwt
from homeassistant.auth.providers import legacy_api_password
from homeassistant.auth.util import generate_secret
from homeassistant.const import HTTP_HEADER_HA_AUTH
from homeass... | fbradyirl/home-assistant | homeassistant/components/http/auth.py | Python | apache-2.0 | 7,407 |
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import * # NOQA
from future import standard_library
standard_library.install_aliases() # NOQA
import chainer
from chainer import functions as F
from chain... | toslunar/chainerrl | tests/agents_tests/basetest_pgt.py | Python | mit | 3,966 |
# 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 may ... | Azure/azure-sdk-for-python | sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/__init__.py | Python | mit | 548 |
"""
Functions for working with "safe strings": strings that can be displayed safely
without further escaping in HTML. Marking something as a "safe string" means
that the producer of the string has already turned characters that should not
be interpreted by the HTML engine (e.g. '<') into the appropriate entities.
"""
f... | vsajip/django | django/utils/safestring.py | Python | bsd-3-clause | 3,885 |
# File name: sidebar.py
import kivy
kivy.require('1.9.0')
import json
from kivy.uix.togglebutton import ToggleButton
from kivy.properties import ObjectProperty
from kivy.lang import Builder
Builder.load_file('sidebar.kv')
class ListItem(ToggleButton):
video = ObjectProperty(None)
def __init__(self, video, ... | pimier15/PyGUI | Kivy/Kivy/Bk_Interractive/sample/Chapter_06_code/09 - ScrollView - displaying a list of videos/sidebar.py | Python | mit | 783 |
"""
Parameter sets with changing the optimization solver.
By default, unspecified options are taken from a previous set. In case of the
first set, defaults are provided in the code. Command-line options can be used
to override the settings below.
Local minimizer methods:
- 'Nelder-Mead'
- 'Powell'
- 'CG'
- '... | rc/dist_mixtures | examples/psets/solvers.py | Python | bsd-3-clause | 1,286 |
from django.http import Http404
from blockcypher.constants import COIN_SYMBOL_MAPPINGS
class assert_valid_coin_symbol(object):
def __init__(self, func):
self.func = func
def __call__(self, request, *args, **kwargs):
if kwargs.get('coin_symbol') not in COIN_SYMBOL_MAPPINGS:
raise... | ychaim/explorer | blockexplorer/decorators.py | Python | apache-2.0 | 381 |
from mongonaut.tests import MongoTestCase
class TestModels(MongoTestCase):
pass
| jazzband/django-mongonaut | examples/blog/articles/tests/test_models.py | Python | mit | 87 |
# Copyright 2015 The TensorFlow Authors. 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 required by applica... | snnn/tensorflow | tensorflow/python/kernel_tests/rnn_test.py | Python | apache-2.0 | 44,433 |
# Like soft_pwm_uasyncio.py, but fading 2 LEDs with different phase.
# Also see original soft_pwm.py.
import uasyncio
from hwconfig import LED, LED2
async def pwm_cycle(led, duty, cycles):
duty_off = 20 - duty
for i in range(cycles):
if duty:
led.value(1)
await uasyncio.sleep_m... | AriZuu/micropython | examples/hwapi/soft_pwm2_uasyncio.py | Python | mit | 779 |
#!/usr/bin/python -u
# Copyright (c) 2010-2012 OpenStack Foundation
#
# 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 ap... | gotostack/swift | test/probe/test_object_handoff.py | Python | apache-2.0 | 9,005 |
from lettuce import step
@step("Given I have some skills in (\w)")
def skill_step(step, languages):
pass
@step("And I want to contribute to an Open Source project")
def skill_step(step):
pass
@step('When I click "Exercise your skills"')
def skill_step(step):
pass
@step("Then I can see a list of projects")
def s... | maria/SkillHub | skillhub/features/skills.py | Python | gpl-3.0 | 1,107 |
__author__ = 'sergey'
import os
import sys
import subprocess
from distutils.core import setup
from distutils.extension import Extension
CYTHON_BUILD = 0
if "--cython-build" in sys.argv:
# Support compiling with Cython
CYTHON_BUILD = 1
sys.argv.remove("--cython-build")
from Cython.Distutils import bu... | sergey-dryabzhinsky/dedupsqlfs | setup.py | Python | mit | 7,206 |
#!/usr/bin/python3
'''See ../README.md'''
import sys, os.path, subprocess, csv, fileinput, shutil, os
from Util import intersperse
def main():
fileLists = {
'Bags' : 'FileLists/CombinedBagsPatchSize21mm.csv',
}
outdirs = {
'ERU' : 'PatchSize21mm/RightUpper',
'ERM' : 'PatchSize21m... | orting/emphysema-estimation | Scripts/SplitCombinedBags.py | Python | gpl-3.0 | 1,836 |
import shlex
from subprocess import Popen,PIPE
import sys
from time import sleep
from dvfs_config import *
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',datefmt='%d/%m/%Y %I:%M:%S %p',\
filename='infoli.log', filemode='a+',level=logging.DEBUG)
#sleep till the ... | A-Kokolis/thesis-ntua | x86_second_implementation/freqChange.py | Python | gpl-3.0 | 730 |
from functools import update_wrapper
from django.http import Http404, HttpResponseRedirect
from django.contrib.admin import ModelAdmin, actions
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.auth import logout as auth_logout, REDIRECT_FIELD_NAME
from django.contrib.contenttypes impor... | edisonlz/fruit | web_project/base/site-packages/django/contrib/admin/sites.py | Python | apache-2.0 | 18,705 |
"""Tests for reviewboard.review.signals."""
from djblets.testing.decorators import add_fixtures
from kgb import SpyAgency
from reviewboard.deprecation import RemovedInReviewBoard40Warning
from reviewboard.reviews.models import ReviewRequest
from reviewboard.reviews.signals import (review_request_closed,
... | reviewboard/reviewboard | reviewboard/reviews/tests/test_signals.py | Python | mit | 1,935 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='DefaultFalse',
fields=[
('id', models.AutoField... | flibbertigibbet/test-drf-booleans | example/migrations/0001_initial.py | Python | lgpl-3.0 | 2,751 |
from django import forms
from texts.models import Text
from contacts.models import Contact
from contacts.forms import ContactForm
class TextForm(forms.ModelForm):
"""Form for new text messages."""
def __init__(self, *args, **kwargs):
super(forms.ModelForm, self).__init__(*args, **kwargs)
self... | pyphonic/Pyphon | pyphon/texts/forms.py | Python | apache-2.0 | 798 |
from os.path import dirname, basename, isfile
import glob
try:
from custom_modules import *
custom_modules = glob.glob(dirname(__file__) + '/custom_modules/*.py')
except:
custom_modules = []
modules = glob.glob(dirname(__file__)+"/*.py") + custom_modules
__all__ = [basename(f)[:-3] for f in modules if ... | VapourApps/va_master | va_master/api/__init__.py | Python | gpl-3.0 | 427 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This progra... | elkingtonmcb/nupic | src/support/pymysqlhelpers.py | Python | agpl-3.0 | 4,300 |
import upseto
import unittest
import gitwrapper
import upsetowrapper
import upseto.manifest
import upseto.gitwrapper
import os
import shutil
import tempfile
import zipfile
class Test(unittest.TestCase):
def setUp(self):
gitwrapper.setUp()
def tearDown(self):
gitwrapper.tearDown()
class S... | Stratoscale/upseto | tests/test.py | Python | apache-2.0 | 21,326 |
# Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
"""
Widgets specific to thread mode
"""
import urwid
import logging
from alot.settings import settings
from alot.db.utils import decod... | meskio/alot | alot/widgets/thread.py | Python | gpl-3.0 | 14,073 |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
from pants.backend.j... | pgroudas/pants | src/python/pants/backend/jvm/targets/java_tests.py | Python | apache-2.0 | 697 |
from golem.interface.command import doc, group, command, CommandResult, Argument, CommandHelper
@group(name="res", help="Manage resources")
class Resources(object):
client = None
provider = Argument(
"--provider",
optional=True,
help="For provider role"
)
requestor = Argumen... | imapp-pl/golem | golem/interface/client/resources.py | Python | gpl-3.0 | 1,335 |
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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 version 2
# of the License, or (at your option) any later version.
#
# This program is distrib... | yukao/Porphyrograph | LYM-sources/SourcesBerfore18/DM/blender/io_DM/__init__.py | Python | gpl-3.0 | 11,517 |
### QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
### Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
###
### 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 ... | StefanoRaggi/Lean | Algorithm.Python/ShortableProviderOrdersRejectedRegressionAlgorithm.py | Python | apache-2.0 | 4,642 |
#!/usr/bin/env python3
# example of low level instructions using dis and a function called countdown
# I wrote this in SLO, downtown. (not the original author, just studying).
import dis
# https://docs.python.org/3/library/dis.html
# bytecode disassembler
def countdown(n):
while n > 0:
print('T-minus', n)
... | csuttles/utils | python/usenix/tale_of_two_concurrencies/part_one/dis_countdown_downtown.py | Python | apache-2.0 | 375 |
import pytest
import rpmlint.spellcheck
from Testing import HAS_CZECH_DICTIONARY, HAS_ENGLISH_DICTIONARY
def get_suggestions(suggestion):
suggestion = suggestion.split(' -> ')[-1]
return sorted(suggestion.split(', '))
@pytest.mark.skipif(not rpmlint.spellcheck.ENCHANT, reason='Missing enchant bindings')
@p... | rpm-software-management/rpmlint | test/test_spellchecking.py | Python | gpl-2.0 | 3,203 |
from nose.tools import *
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
from qualitio.core.tests.utils import BaseTestCase
from qualitio.core.tests.testapp.models import File, Directory, FileNotUnique
class FileTest(BaseTestCase):
def setUp(self):
self.addTe... | qualitio/qualitio | qualitio/core/tests/models.py | Python | gpl-3.0 | 3,378 |
#!/usr/bin/env python
from flask.ext.script import Manager
from flask_frozen import Freezer
import discovery
import logging
out = logging.StreamHandler()
out.setFormatter(logging.Formatter())
out.setLevel(logging.DEBUG)
logging.getLogger('freepto-web').setLevel(logging.INFO)
logging.getLogger('freepto-web').addHandler... | vinc3nt/freepto-web | manage.py | Python | gpl-2.0 | 842 |
#! /usr/bin/python
"""
test_xbee.py
By Paul Malmsten, 2010
pmalmsten@gmail.com
Tests the XBeeBase superclass module for XBee API conformance.
"""
import unittest
from xbee.base import XBeeBase
from xbee.tests.Fake import FakeDevice, FakeReadDevice
class TestWriteToDevice(unittest.TestCase):
"""
XBeeBase clas... | MengGuo/Jackal_Velodyne_Duke | xbee_communication/XBee-2.2.3/xbee/tests/test_base.py | Python | gpl-2.0 | 5,670 |
class ShirtsioError(Exception):
def __init__(self, message=None, http_body=None, http_status=None, json_body=None):
super(ShirtsioError, self).__init__(message)
self.http_body = http_body and http_body.decode('utf-8')
self.http_status = http_status
self.json_body = json_body
class ... | harpesichord/Door-Access | door/exception.py | Python | mit | 679 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.