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 |
|---|---|---|---|---|---|
# -*- coding: utf-8 -*-
"""
flask.sessions
~~~~~~~~~~~~~~
Implements cookie based sessions based on itsdangerous.
:copyright: (c) 2015 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import uuid
import hashlib
from base64 import b64encode, b64decode
from datetime import dateti... | lord63-forks/flask | flask/sessions.py | Python | bsd-3-clause | 14,332 |
from nested_serializers import NestedModelSerializer
from rest_framework import serializers
from example.app.models import Channel, Video
class ChannelSerializer(serializers.ModelSerializer):
class Meta(object):
model = Channel
class VideoSerializer(NestedModelSerializer):
class Meta(object):
... | theonion/djesrf | example/app/serializers.py | Python | mit | 355 |
""" __slots__的值表示只允许对象绑定的属性 """
from types import MethodType
class Student(object):
# 定义属性允许绑定的属性或者方法名,限制性不会传递到子类
__slots__ = ('name', 'age', 'tts')
# 上面的标签不妨碍类定义属性
city = 'CQ'
# 子类没有限制, 如果子类加了 __slots__ ,则子类实例的类型的属性范围为父子类合并
class GraduateStudent(Student):
pass
class ChinaStudent(Student):
... | lucd1990/self-learn-python | oop_senior/slots_test.py | Python | unlicense | 1,173 |
"""Tests for certbot.error_handler."""
import contextlib
import os
import signal
import sys
import unittest
import mock
def get_signals(signums):
"""Get the handlers for an iterable of signums."""
return dict((s, signal.getsignal(s)) for s in signums)
def set_signals(sig_handler_dict):
"""Set the signa... | nohona/cron-crm | usr/local/certbot/certbot/tests/error_handler_test.py | Python | gpl-3.0 | 3,897 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Author : <github.com/tintinweb>
import unittest
import json
from evmlab.tools.statetests import rndval
import evmlab.tools.statetests.templates
class EthFillerObjectifiedTest(unittest.TestCase):
def setUp(self):
rndval.RandomSeed.set_state(None) # genera... | holiman/evmlab | tests/tools/statetests/test_objectified.py | Python | gpl-3.0 | 974 |
from __future__ import unicode_literals
from django.conf import settings
import six.moves.urllib.parse as urlparse
from horizon.utils.memoized import memoized # noqa
import requests
import json
@memoized
def get_token(request):
return request.user.token.id
# ----------------------------------------------------... | Crystal-SDS/dashboard | crystal_dashboard/api/controllers.py | Python | gpl-3.0 | 4,593 |
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2015 Université Catholique de Louvain.
#
# This file is part of INGInious.
#
# INGInious is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 o... | GuillaumeDerval/INGInious | frontend/pages/course_admin/settings.py | Python | agpl-3.0 | 4,059 |
# -*- coding: utf-8 -*-
# Test the support for SSL and sockets
import sys
import unittest
from test import test_support as support
from test.script_helper import assert_python_ok
import asyncore
import socket
import select
import time
import datetime
import gc
import os
import errno
import pprint
import shutil
import ... | HiSPARC/station-software | user/python/Lib/test/test_ssl.py | Python | gpl-3.0 | 144,422 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Interpreter version: python 2.7
#
# !!! DO NOT EDIT THIS FILE - THIS IS GENERATED FILE !!!
# Imports =====================================================================
from collections import namedtuple
# Functions and classes =====================================... | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/structures/comm/publication.py | Python | mit | 2,401 |
"""Http json-rpc client transport implementation."""
import requests
import logging
# configure logger
_logger = logging.getLogger(__name__)
_logger.setLevel(logging.ERROR)
class HttpClient(object):
"""json-rpc http client transport."""
def __init__(self, url):
"""
Create HttpC... | tvannoy/jsonrpc_pyclient | jsonrpc_pyclient/connectors/httpclient.py | Python | mit | 1,247 |
import os
import unittest
import waftester
import devkitarm
import Build
import Utils
def DKAConf(conf):
conf.check_tool('devkitarm')
def DKABuild(bld):
pass
def DKAWithCompiler(conf):
conf.check_tool('devkitarm')
conf.check_tool('compiler_cxx')
conf.check_tool('compiler_cc')
def DKAWithLibnds(c... | google-code-export/quirkysoft | waf_tools/test_devkitarm.py | Python | gpl-3.0 | 3,052 |
from flask import Flask
from flask.ext.restful import reqparse, abort, Api, Resource
app = Flask(__name__)
api = Api(app)
QUESTIONS = {
'1': {'question': 'How do we do XY?', 'answers': {'1': 'We do it like that...', '2': 'lalala ...'}},
'2': {'question': 'Where to find XY?', 'answers': {'3': 'It is found here... | thorbenegberts/qali | qali/app.py | Python | apache-2.0 | 1,874 |
from sympy import (S, sympify, trigsimp, expand, sqrt, Add, zeros,
ImmutableMatrix as Matrix)
from sympy.core.compatibility import u, unicode
from sympy.utilities.misc import filldedent
__all__ = ['Vector']
class Vector(object):
"""The class used to define vectors.
It along with Reference... | beni55/sympy | sympy/physics/vector/vector.py | Python | bsd-3-clause | 22,112 |
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 28 16:52:18 2016 by emin
"""
import os
import sys
import theano
import theano.tensor as T
import numpy as np
from lasagne.layers import InputLayer, ReshapeLayer, DenseLayer
from generators import CoordinateTransformationTaskFFWD
import lasagne.layers
import lasagne.nonline... | eminorhan/inevitable-probability | nin_nhu/ninnhu_coordinate_transformation_expt.py | Python | gpl-3.0 | 4,919 |
class Solution:
def numberOfPatterns(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
def valid(pre_key, key, used):
if not pre_key: return True
px, py = (pre_key-1) // 3, (pre_key-1) % 3
x, y = (key-1) // 3, (key-1) % 3
... | YiqunPeng/Leetcode-pyq | solutions/351AndroidUnlockPatterns.py | Python | gpl-3.0 | 1,648 |
# encoding: 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 model 'Dogodek'
db.create_table('infosys_dogodek', (
('id', self.gf('django.db.model... | bancek/egradebook | src/apps/infosys/migrations/0007_auto__add_dogodek__chg_field_ocena_datum_pridobitve.py | Python | gpl-3.0 | 12,753 |
# -*- coding: utf-8 -*-
# Copyright 2022 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... | googleapis/python-game-servers | samples/generated_samples/gameservices_v1beta_generated_game_server_clusters_service_list_game_server_clusters_async.py | Python | apache-2.0 | 1,629 |
class Hack:
def push_selection(self, a):
print("push_selection not implemented")
pass
def get_jump_history(a):
print("get_jump_history not implemented")
return Hack()
| farhaanbukhsh/lime | packages/Default/history_list.py | Python | bsd-2-clause | 198 |
# PyAutoGUI: Cross-platform GUI automation for human beings.
# BSD license
# Al Sweigart al@inventwithpython.com (Send me feedback & suggestions!)
"""
IMPORTANT NOTE!
To use this module on Mac OS X, you need the PyObjC module installed.
For Python 3, run:
sudo pip3 install pyobjc-core
sudo pip3 install pyobjc... | osspeak/osspeak | osspeak/pyautogui/__init__.py | Python | mit | 36,647 |
from datetime import datetime, timedelta
from freezegun import freeze_time
from mock import MagicMock
import pytest
from pytz import utc
from scanomatic.data.scanjobstore import ScanJobStore
from scanomatic.models.scanjob import ScanJob
from scanomatic.scanning.terminate_scanjob import (
TerminateScanJobError, Un... | Scan-o-Matic/scanomatic | tests/unit/scanning/test_terminate_scanjob.py | Python | gpl-3.0 | 2,729 |
"""Foolscap"""
from ._version import get_versions
__version__ = str(get_versions()['version'])
del get_versions
| warner/foolscap | src/foolscap/__init__.py | Python | mit | 113 |
#
# Copyright (C) 2012-2014 The Python Software Foundation.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
import codecs
from collections import deque
import contextlib
import csv
from glob import iglob as std_iglob
import io
import json
import logging
import os
import py_compile
import re
import shutil
import socket
import... | gusai-francelabs/datafari | windows/python/Lib/site-packages/pip/_vendor/distlib/util.py | Python | apache-2.0 | 51,453 |
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
# 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 limi... | HewlettPackard/python-hpOneView | examples/volumes.py | Python | mit | 7,563 |
#!/usr/bin/env python
# Mininet Automatic Testing Tool (Prototype)
# Copyright (C) 2013 Jesse J. Cook
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, o... | CrashenX/auto-grader | src/auto-grade.py | Python | agpl-3.0 | 9,526 |
import os
import socket
import subprocess
import signal
import sys
import logging
import time
# - execute a process
#print 'executing process 1...'
#executable='sleep'
#param='3'
#subprocess.call([executable, param])
#print 'executing process 2...'
#os.system('sleep 1')
# - capture SIGINT and other signals
#print 'd... | ow2-compatibleone/accords-platform | paprocci/test/to-cosacs/miscco.py | Python | apache-2.0 | 1,228 |
import time
import treetests
import pdb
import sys
def speedysort(mylist):
helpspeedysort(mylist, 0, len(mylist))
return mylist
def helpspeedysort(mylist, start, end):
if end - start <= 1:
return mylist
pivot = start
pivotval = mylist[pivot]
for i in xrange(start+1, end):
if my... | sniboboof/data-structures | sortquickly.py | Python | mit | 1,111 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from math import ceil
from django.db import migrations, models
def get_partner(org, user):
return user.partners.filter(org=org, is_active=True).first()
def calculate_totals_for_cases(apps, schema_editor):
from casepro.statistics.models import... | praekelt/casepro | casepro/statistics/migrations/0010_existing_case_timings_count.py | Python | bsd-3-clause | 4,962 |
"""invoke task file to build CSS"""
from invoke import task, run
import os
from distutils.version import LooseVersion as V
from subprocess import check_output
pjoin = os.path.join
static_dir = 'static'
components_dir = pjoin(static_dir, 'components')
here = os.path.dirname(__file__)
min_less_version = '1.7.5'
max_le... | mattvonrocketstein/smash | smashlib/ipy3x/html/tasks.py | Python | mit | 3,210 |
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Defines a Trajectory class, and a routine to extract a sub-cube along a
trajectory.
"""
import math
import numpy as np
f... | pp-mo/iris | lib/iris/analysis/trajectory.py | Python | lgpl-3.0 | 35,223 |
import os
import signal
import yaml
from gi.repository import Gtk
from gi.repository import GLib
from pylsner import gui
class Loader(yaml.Loader):
def __init__(self, stream):
self._root = os.path.split(stream.name)[0]
super(Loader, self).__init__(stream)
def include(self, node):
f... | mrmrwat/pylsner | pylsner/__init__.py | Python | mit | 2,028 |
# -*- coding: utf-8 -*-
from distutils.version import LooseVersion
from classytags.core import Tag, Options
import django
from django import template
from django.core.serializers.json import DjangoJSONEncoder
from django.utils.text import javascript_quote
DJANGO_1_4 = LooseVersion(django.get_version()) < LooseVersion... | mpetyx/palmdrop | venv/lib/python2.7/site-packages/cms/templatetags/cms_js_tags.py | Python | apache-2.0 | 1,001 |
""" Sahana Eden Module Automated Tests - INV001 Send Items
@copyright: 2011-2012 (c) Sahana Software Foundation
@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 w... | gallifrey17/eden | modules/tests/inv/send_item.py | Python | mit | 3,148 |
# vim: set et nosi ai ts=2 sts=2 sw=2:
# coding: utf-8
from __future__ import absolute_import, print_function, unicode_literals
import unittest
from schwa import tokenizer
import six
INPUT = r'''
<h1>This is a page title</h1>
<p>Once upon a time, there was a "sentence" with:</p>
<ul>
<li>One dot point</li>
<li>A... | schwa-lab/libschwa-python | tests/test_tokenizer.py | Python | mit | 4,752 |
@micropython.asm_thumb
def f(r0, r1, r2):
push({r0})
push({r1, r2})
pop({r0})
pop({r1, r2})
print(f(0, 1, 2))
| kerneltask/micropython | tests/inlineasm/asmpushpop.py | Python | mit | 128 |
from pyperator.decorators import inport, outport, component, run_once
from pyperator.nodes import Component
from pyperator.DAG import Multigraph
from pyperator.utils import InputPort, OutputPort
import pyperator.components | baffelli/pyperator | pyperator/__init__.py | Python | mit | 222 |
import mock
from decimal import Decimal as D
from xml.dom.minidom import parseString
from django.test import TestCase
from oscar.apps.payment.datacash.utils import Gateway
class AuthResponseHandlingTests(TestCase):
success_response_xml = """<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<CardTxn>
... | aykut/django-oscar | oscar/apps/payment/tests/datacash_responses.py | Python | bsd-3-clause | 5,345 |
from django.conf.urls import include, url
from django.views.generic.base import TemplateView
from rest_framework import routers
from . import views
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'books', views.BookViewSet)
... | narsi84/digilib | gui/urls.py | Python | mit | 929 |
class Solution:
def longestMountain(self, A: List[int]) -> int:
if not A or len(A) < 3:
return 0
result = 0
for i in range(1, len(A)-1):
total = 1
if A[i-1] < A[i] and A[i] > A[i+1]:
pre = i - 1
nxt = i + 1
... | MingfeiPan/leetcode | two_pointers/845.py | Python | apache-2.0 | 767 |
from PyQt5 import QtCore, QtGui, QtWidgets
import os
import scanner
import utils
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, root, parent=None):
super(MainWindow, self).__init__(parent)
datadir = os.path.dirname(os.path.abspath(__file__))
self.setWindowIcon(QtGui.QIcon(os.p... | amirgeva/commit | mainwindow.py | Python | gpl-2.0 | 3,793 |
# coding: utf-8
# pylint: disable=too-few-public-methods, no-self-use, missing-docstring, unused-argument
from flask_restful import reqparse, Resource
from flask import abort
from main import API
import task
import config
from api.helpers import ArgumentValidator, make_empty_ok_response
from api.decorators import verif... | madvas/gae-angular-material-starter | main/api/v1/feedback_api.py | Python | mit | 1,108 |
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.exceptions import UserError
from odoo.tests import SavepointCase
class TestSaleOrderLinePackagingQty(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env... | OCA/sale-workflow | sale_order_line_packaging_qty/tests/test_sale_order_line_packaging_qty.py | Python | agpl-3.0 | 4,006 |
import json
import time
from _md5 import md5
import requests
import RolevPlayer as r
def now_playing_last_fm(artist, track):
update_now_playing_sig = md5(("api_key" + r.API_KEY +
"artist" + artist +
"method" + "track.updateNowPlaying" +
... | SimeonRolev/RolevPlayerQT | RolevPlayer/Scrobbler.py | Python | gpl-3.0 | 1,642 |
# Jiao Lin <jiao.lin@gmail.com>
"""
make phonon Density of States nicer by fitting starting curve to a parabolic
"""
import numpy as np
def nice_dos(E, g):
# .. in crease number of points if necessary
if len(E) < 500:
dE = E[-1]/500.
E1 = np.arange(0, E[-1], dE)
g1 = np.interp(E1, E... | sns-chops/multiphonon | multiphonon/dos/nice.py | Python | mit | 3,668 |
# Python example script that uses the RcalculatorFilter to compute the mean
# vertex degree of the input graph and the distance from the mean for each
# vertex in the entire graph. The computed result is then used to label
# the displayed graph in VTK.
# VTK must be built with VTK_USE_GNU_R turned on for this exampl... | berendkleinhaneveld/VTK | Examples/Infovis/Python/Rcalculator_vd.py | Python | bsd-3-clause | 2,298 |
"""
This is an example plugin about how to use triggers
## Using
### Add the regex
* ```self.api('triggers.add')('testtrig', "^some test$")```
### Register a function to the event
* ```self.api('events.register('trigger_testtrig', somefunc)
"""
from plugins._baseplugin import BasePlugin
NAME = 'Trigger Example'
SNA... | endavis/bastproxy | plugins/example/triggerex.py | Python | gpl-2.0 | 1,063 |
# -*- encoding: utf-8 -*-
from openerp import models, fields, api
class Wizard(models.TransientModel):
_name = 'openacademy.wizard'
def _default_sessions(self):
return self.env['openacademy.session'].browse(self._context.get('active_ids'))
session_ids = fields.Many2many('openacademy.session',
... | cmexiatyp/open_academy | model/wizard.py | Python | apache-2.0 | 611 |
# LANGUAGE: Python
# ENV: Python3.5
# AUTHOR: Artur Baruchi
# GITHUB: https://github.com/abaruchi
a = "Hello"
b = "World"
print("{} {}".format(a, b))
| bikoheke/hacktoberfest | scripts/hello_world_abaruchi.py | Python | gpl-3.0 | 151 |
#!/usr/bin/env python
## \file square.py
# \brief Python script for creating grid for freesurface channels.
# \author Aerospace Design Laboratory (Stanford University) <http://su2.stanford.edu>.
# \version 2.0.6
#
# Stanford University Unstructured (SU2) Code
# Copyright (C) 2012 Aerospace Design Laboratory
#
# Th... | AmritaLonkar/trunk | SU2_PY/2DChannel.py | Python | gpl-2.0 | 7,901 |
# Import the Video model we created in our video_app/models.py
from .models import Video
from rest_framework import serializers
class VideoSerializer(serializers.ModelSerializer):
""" Class to serialize data between Django models and database. """
class Meta:
model = Video
fields = ('author_... | NazimAli2017/Django-Rest-API-Videos | video_api/video_app/serializers.py | Python | gpl-3.0 | 404 |
# -*- coding: utf-8 -*-
# © 2016 Chafique DELLI @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Purchase Picking State',
'summary': 'Add the status of all the incoming picking'
' in the purchase order',
'version': '9.0.1.0.0',
'category': 'Purchase Manageme... | SerpentCS/purchase-workflow | purchase_picking_state/__openerp__.py | Python | agpl-3.0 | 561 |
#!/usr/bin/env python
#
# Use the LasarScan to compute the distance to any obstacle in a region in front
# of the robot. The region has a width specified as a parameter.
#
# Package: teleop_service. Width parameter = "robot/width"
# Refresh interval used to slow down the publication rate
#
import rospy
import ... | chuckcoughlin/sarah-bella | robot/src/audio_locator/src/monitor_audio_signal.py | Python | mit | 1,473 |
from hc.api.models import Channel, Check
from hc.test import BaseTestCase
class ApiAdminTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.check = Check.objects.create(project=self.project, tags="foo bar")
self.alice.is_staff = True
self.alice.is_superuser = True
... | healthchecks/healthchecks | hc/api/tests/test_admin.py | Python | bsd-3-clause | 688 |
#!/usr/bin/env python
from datetime import datetime, timedelta
import time
import dns
from dnsdisttests import DNSDistTest
class TestResponseRuleNXDelayed(DNSDistTest):
_config_template = """
newServer{address="127.0.0.1:%s"}
addResponseAction(RCodeRule(DNSRCode.NXDOMAIN), DelayResponseAction(1000))
"... | shinsterneck/pdns | regression-tests.dnsdist/test_Responses.py | Python | gpl-2.0 | 10,719 |
from typing import Tuple, Union
import moderngl
from demosys.resources.meta import ProgramDescription
from demosys import context
VERTEX_SHADER = 'VERTEX_SHADER'
GEOMETRY_SHADER = 'GEOMETRY_SHADER'
FRAGMENT_SHADER = 'FRAGMENT_SHADER'
TESS_CONTROL_SHADER = 'TESS_CONTROL_SHADER'
TESS_EVALUATION_SHADER = 'TESS... | Contraz/demosys-py | demosys/opengl/program.py | Python | isc | 8,649 |
#!/usr/bin/python2.4
# Gscreen a GUI for linuxcnc cnc controller
# Chris Morley copyright 2012
#
# 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,... | CalvinHsu1223/LinuxCNC-EtherCAT-HAL-Driver | src/emc/usr_intf/gscreen/gscreen.py | Python | gpl-2.0 | 151,811 |
from django.contrib.auth.models import User as AuthUser
from django.core.urlresolvers import resolve
from django.http import HttpRequest
from django.template.loader import render_to_string
from django.test import TestCase
from django.utils.html import escape
import json
from mock import patch
from server.models import... | raspberrywhite/raspberrywhite | server/tests/test_views.py | Python | bsd-3-clause | 3,820 |
from utils import *
from config import *
from .flightblock import FlightBlockList
from .waypointobject import Waypoint
import config
import utm
import logging
import threading
from collections import OrderedDict
from PyQt5.QtCore import QObject, pyqtSignal
logg = logging.getLogger(__name__)
class BagOfHolding(objec... | uaarg/missioncommander | database/database.py | Python | gpl-2.0 | 8,144 |
#
# Copyright (c) 2011 Ginkgo Bioworks Inc.
# Copyright (c) 2011 Daniel Taub
#
# This file is part of Scantelope.
#
# Scantelope 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 3 of the L... | dmtaub/scantelope | decode.py | Python | gpl-3.0 | 5,157 |
# Copyright 2020 Google Research. 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 applicable law... | tensorflow/examples | tensorflow_examples/lite/model_maker/third_party/efficientdet/keras/util_keras.py | Python | apache-2.0 | 9,468 |
from .particles import (
drift_kick,
process_sink,
produce_ptcls,
Ensemble,
json_to_ensemble,
ensemble_to_json,
Sink,
SinkPlane,
Source,
)
from .coulomb import (
CoulombForce
)
from .bend_kick import (
bend_kick
)
from .radiation_pressure import (
RadiationPressur... | d-meiser/cold-atoms | src/coldatoms/__init__.py | Python | gpl-3.0 | 459 |
# -*- coding: utf-8 -*-
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
from flask.ext.mail import Mail
mail = Mail()
from flask.ext.login import LoginManager
login_manager = LoginManager()
from flask.ext.babel import Babel
babel = Babel()
| vovantics/flask-bluebone | app/extensions.py | Python | mit | 258 |
#!/usr/bin/env python3
"""Tests bsp's -c' and '-C' options
TODO: test error cases ('-c' set to non-existent file; invalid values for
'--bool-config-value', '--int-config-value', '--float-config-value';
config conflicts; etc.)
"""
import datetime
import json
import logging
import os
import subprocess
import s... | pnwairfire/bluesky | test/adhoc/test_bsp_config_options.py | Python | gpl-3.0 | 5,273 |
r"""
Diametrically point loaded 2-D disk with postprocessing and probes. See
:ref:`sec-primer`.
Use it as follows (assumes running from the sfepy directory; on Windows, you
may need to prefix all the commands with "python " and remove "./"):
1. solve the problem::
./simple.py examples/linear_elasticity/its2D_4.py... | sfepy/sfepy | examples/linear_elasticity/its2D_4.py | Python | bsd-3-clause | 4,331 |
import random
import numpy as np
from deap import base
from deap import creator
from deap import tools
from deap import algorithms
import argparse
import pandas
import os
import numpy as np
import matplotlib.pyplot as plt
import functools
from collections import Counter
import math
import random
def accuracy(decision... | aquemy/HCBR | script/genetic_algorithm.py | Python | mit | 11,500 |
"""Shared OS X support functions."""
import os
import re
import sys
__all__ = [
'compiler_fixup',
'customize_config_vars',
'customize_compiler',
'get_platform_osx',
]
# configuration variables that may contain universal build flags,
# like "-arch" or "-isdkroot", that may need customization for
# the... | lfcnassif/MultiContentViewer | release/modules/ext/libreoffice/program/python-core-3.3.0/lib/_osx_support.py | Python | lgpl-3.0 | 18,472 |
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
##
## CDS Invenio 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 (... | ppiotr/Bibedit-some-refactoring | modules/websubmit/lib/functions/Print_Success_MBI.py | Python | gpl-2.0 | 1,591 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-14 17:48
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('member', '0014_auto_20170911_2147'),
]
operations = [
migrations.AlterField... | comcidis/portal | member/migrations/0015_auto_20170914_1748.py | Python | mit | 457 |
import unittest
import httplib
import plistlib
import os.path
from mock import Mock
from airpnp.AirPlayService import AirPlayService
from airpnp.airplayserver import IAirPlayServer
from cStringIO import StringIO
from twisted.web import http, server
from twisted.internet import defer
from twisted.test.proto_helpers impo... | provegard/airpnp | test/test_airplayservice.py | Python | bsd-3-clause | 7,784 |
#
# Copyright (c) 2005 Red Hat, Inc.
#
# Written by Joel Martin <jmartin@redhat.com>
#
# This file is part of Smart Package Manager.
#
# Smart Package Manager 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; ei... | dmacvicar/spacewalk | client/solaris/smartpm/smart/backends/solaris/base.py | Python | gpl-2.0 | 3,072 |
def get_credentials(client_secret=None):
"""Gets valid user credentials from storage.
If nothing has been stored, or if the stored credentials are invalid,
the OAuth2 flow is completed to obtain the new credentials.
Returns:
Credentials, the obtained credential.
"""
import sys
sys... | qualdocs/qualdocs | qualdocs/get_credentials.py | Python | mit | 1,213 |
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'openlc.views.home', name='home'),
# url(r'^blog/', include('blog.urls'))... | Gorgel/khd_projects | khd_projects/khd_projects/urls.py | Python | mit | 890 |
"""
mbed CMSIS-DAP debugger
Copyright (c) 2017 ARM Limited
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... | mesheven/pyOCD | pyocd/utility/progress.py | Python | apache-2.0 | 4,370 |
"""
Functional test
Big Share Admin Epic
Storyboard is defined within the comments of the program itself
"""
import unittest
from flask import url_for
from biblib.views.http_errors import NO_PERMISSION_ERROR
from biblib.tests.stubdata.stub_data import UserShop, LibraryShop, fake_biblist
from biblib.tests.base import... | jonnybazookatone/biblib-service | biblib/tests/functional_tests/test_big_share_admin_epic.py | Python | mit | 11,039 |
"""Implements the Astropy TestRunner which is a thin wrapper around pytest."""
import inspect
import os
import glob
import copy
import shlex
import sys
import tempfile
import warnings
import importlib
from collections import OrderedDict
from importlib.util import find_spec
from functools import wraps
from astropy.con... | StuartLittlefair/astropy | astropy/tests/runner.py | Python | bsd-3-clause | 22,724 |
# Copyright 2017 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... | npuichigo/ttsflow | third_party/tensorflow/tensorflow/python/grappler/layout_optimizer_test.py | Python | apache-2.0 | 3,838 |
__author__ = 'parallels'
import pika
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.CRITICAL)
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body... | bkolowitz/IADSS | ml/recieve.py | Python | apache-2.0 | 552 |
# Copyright 2014 Yajie Miao Carnegie Mellon University
# 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
#
# THIS CODE IS PROVIDED *AS IS* B... | mclaughlin6464/pdnn | cmds2/run_DNN_2Tower.py | Python | apache-2.0 | 6,638 |
from __future__ import unicode_literals
class Status(object):
"""Sharing status.
ACCEPTED: An accepted and active share
DECLINED: declined share
PENDING: pending share waiting on user's response
INACTIVE: once an accepted share, now is no longer sharing
"""
ACCEPTED = 'ACCEPTED'
DECLI... | InfoAgeTech/django-shares | django_shares/constants.py | Python | mit | 814 |
# coding=utf-8
# Copyright 2015 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)
import pytest
from p... | areitz/pants | tests/python/pants_test/bin/test_goal_runner.py | Python | apache-2.0 | 1,149 |
#!/usr/bin/python3
"""
Request the route /permissions/doctype/:doctype/sharedWithMe to get all the
permissions that apply to the documents of the provided doctype that were
shared to the user.
"""
import logging
import subprocess
import sys
import createoauthclientandtoken
logging.basicConfig(format='%(levelname)s:%... | Ljinod/Misc | scripts/python/getsharedwithmepermissions.py | Python | mit | 1,859 |
# Generated by Django 2.2.24 on 2021-11-11 08:49
import django.core.validators
from django.db import migrations, models
from django.db.models import Count
def add_shard_to_no_rule_configurations(apps, schema_editor):
Configuration = apps.get_model("santa", "Configuration")
for configuration in Configuration.... | zentralopensource/zentral | zentral/contrib/santa/migrations/0026_configuration_allow_unknown_shard.py | Python | apache-2.0 | 1,128 |
# -*- coding: utf-8 -*-
# Copyright 2022 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... | googleapis/python-game-servers | samples/generated_samples/gameservices_v1_generated_game_server_configs_service_list_game_server_configs_sync.py | Python | apache-2.0 | 1,581 |
#!/usr/bin/env python
# Copyright 2016 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.
__doc__ = """generate_resource_whitelist.py [-o OUTPUT] INPUTS...
INPUTS are paths to unstripped binaries or PDBs containing reference... | endlessm/chromium-browser | tools/resources/generate_resource_whitelist.py | Python | bsd-3-clause | 4,853 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-03-02 12:48
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('libreosteoweb', '0031_paimentmean'),
]
operations = [
migrations.AlterModelOptions(
... | littlejo/Libreosteo | libreosteoweb/migrations/0032_auto_20180302_1348.py | Python | gpl-3.0 | 409 |
""" Test for the remove.py module in the vcontrol/rest/providers directory """
from os import remove as delete_file
from web import threadeddict
from vcontrol.rest.providers import remove
PROVIDERS_FILE_PATH = "../vcontrol/rest/providers/providers.txt"
class ContextDummy():
env = threadeddict()
env['HTTP_HO... | CyberReboot/vcontrol | tests/test_rest_providers_remove.py | Python | apache-2.0 | 2,487 |
# Copyright 2009 Kieran Elliott <kierse@mediarover.tv>
#
# Media Rover 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 3 of the License, or
# (at your option) any later version.
#
# Media Rover... | kierse/mediarover | mediarover/source/DEPRECATED/tvnzb/__init__.py | Python | gpl-3.0 | 1,854 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# 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.apa... | inkerra/cinder | cinder/brick/initiator/linuxfc.py | Python | apache-2.0 | 4,945 |
import pandas as pd
import numpy as np
def preprocess(k, v):
tmp = pd.DataFrame(v)
tmp['id'] = ['%s-%d' %(k, i) for i in range(tmp.shape[0])]
tmp = pd.melt(tmp, id_vars = ['id'])
tmp['src'] = k
tmp['hash'] = tmp.variable.apply(lambda x: k + '-' + x)
tmp.rename(columns = {'val... | bkj/wit | wit/helper_functions.py | Python | apache-2.0 | 1,832 |
import pytest
from api.base.settings.defaults import API_BASE
from framework.auth.core import Auth
from website.util import disconnected_from_listeners
from website.project.signals import contributor_removed
from osf_tests.factories import (
NodeFactory,
AuthUserFactory,
RegistrationFactory
)
@pytest.fix... | leb2dg/osf.io | api_tests/registrations/views/test_registration_linked_nodes.py | Python | apache-2.0 | 15,112 |
import psycopg2
from psycopg2 import extras
import math
import string
import sys
import settingReader # Read the XML settings
import logging
class DBConnection(object):
def __init__(self,Options,ConnectToDefaultDB=False):
self.ConnectionOpened=False
self.QueriesCount=0
self.Opt... | IntersectAustralia/asvo-tao | core/sageimport_mpi_HDF/DatabaseSecurity.py | Python | gpl-3.0 | 4,647 |
import sys
import smtplib
def output((code, msg)):
sys.stdout.write('%s %s\n' % (code, msg))
sys.stdout.flush()
smtp = smtplib.SMTP('localhost', 2500)
output(smtp.ehlo('moon.localdomain'))
print smtp.esmtp_features
output(smtp.mail('Damien Churchill <damoxc@gmail.com>'))
output(smtp.rcpt('Damien Churchill <da... | damoxc/vsmtpd | test_smtp.py | Python | gpl-3.0 | 406 |
# construct groups of connected images. The inclusion order favors
# images with the most connections (features matches) to neighbors.
import cv2
import json
import math
import numpy as np
import os
import sys
from props import getNode
from .logger import log
#min_group = 10
min_group = 7
min_connections = 25
max_... | UASLab/ImageAnalysis | scripts/lib/groups.py | Python | mit | 5,436 |
from django.contrib import admin
from models import SensorType, SensorData
def clear_sensor_data(model_admin, request, queryset):
for sensor_type in queryset:
SensorData.objects.filter(type=sensor_type).delete()
clear_sensor_data.short_description = "Clear sensor data"
class SensorTypeAdmin(admin.ModelA... | circuitar/SensorMonitor | SensorMonitorPanel/admin.py | Python | mit | 443 |
# -*- encoding: utf-8 -*-
#
# Copyright 2013 IBM Corp.
#
#
# 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... | citrix-openstack-build/pycadf | pycadf/audit/api.py | Python | apache-2.0 | 11,858 |
# -*- coding: utf-8 -*-
"""django_treensl URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', vie... | EvgeniyBurdin/django_treensl | django_treensl/urls.py | Python | bsd-3-clause | 830 |
# -*- coding: utf-8
# pylint: disable=line-too-long
"""Simple KMers class to compute kmer frequecies
This module should not be used for k > 4.
"""
import itertools
from collections import Counter
import anvio
from anvio.constants import complements
__author__ = "Developers of anvi'o (see AUTHORS.txt)"
__copyr... | meren/anvio | anvio/kmers.py | Python | gpl-3.0 | 2,263 |
class Mover(object):
def __init__(self):
self.location = PVector(random(width), random(height))
self.velocity = PVector(0, 0)
self.topspeed = 4
self.r = 15
def update(self):
mouse = PVector(mouseX, mouseY)
dir = PVector.sub(mouse, self.location)
... | kantel/processingpy | sketches/natureOfCode/chapter01/mover5/mover.py | Python | mit | 1,075 |
# Copyright 2014 Mellanox Technologies, Ltd
#
# 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 t... | bigswitch/neutron | neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py | Python | apache-2.0 | 20,317 |
"""
Support for MQTT lights.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.mqtt/
"""
import logging
from functools import partial
import voluptuous as vol
import blumate.components.mqtt as mqtt
from blumate.components.light import (
ATTR_BRI... | bdfoster/blumate | blumate/components/light/mqtt.py | Python | mit | 8,685 |
# Copyright 2017 Huawei Technologies Co.,LTD.
# 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
#
# Unl... | openstack/nomad | cyborg/objects/base.py | Python | apache-2.0 | 6,515 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.