code stringlengths 2 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int32 2 1.05M |
|---|---|---|---|---|---|
# 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)
import glob
import o... | jtrobec/pants | tests/python/pants_test/backend/python/tasks/test_pytest_run.py | Python | apache-2.0 | 14,508 |
# 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 (t... | apache/allura | Allura/allura/model/repo_refresh.py | Python | apache-2.0 | 11,877 |
import time
import sys
import os
import threading
import ConfigParser
from common import CommonVariables
from pwd import getpwuid
from stat import *
import traceback
# [pre_post]
# "timeout" : (in seconds),
#
# .... other params ...
#
# "pluginName0" : "oracle_plugin", the python plugin f... | varunkumta/azure-linux-extensions | VMBackup/main/PluginHost.py | Python | apache-2.0 | 11,336 |
# Copyright (C) 2014, Hitachi, 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... | Accelerite/cinder | cinder/volume/drivers/hitachi/hbsd_iscsi.py | Python | apache-2.0 | 16,787 |
#!/usr/bin/env python2.6
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2009,2010,2013 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... | stdweird/aquilon | tests/aqdb/test_metacluster.py | Python | apache-2.0 | 5,010 |
from __future__ import unicode_literals
import os
import threading
import time
import unittest
from prometheus_client import Gauge, Counter, Summary, Histogram, Metric
from prometheus_client import CollectorRegistry, generate_latest, ProcessCollector
from prometheus_client import push_to_gateway, pushadd_to_gateway, ... | alexander-95/client_python | tests/test_client.py | Python | apache-2.0 | 22,394 |
# Copyright 2011 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 or agreed to in writing,... | flackr/quickopen | src/prelaunch_client_test.py | Python | apache-2.0 | 1,291 |
#!/usr/bin/python
# coding: utf-8
# 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... | arenadata/ambari | dev-support/docker/docker/bin/ambaribuild.py | Python | apache-2.0 | 8,584 |
'''
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "... | duplocloud/duploiotagent | samples/basicShadow/basicShadowUpdater.py | Python | apache-2.0 | 5,041 |
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os, sys
from ipdl.ast import Visitor
from ipdl.ast import IN, OUT, INOUT, ASYNC, SYNC, RPC
class CodePrinter:
... | sergecodd/FireFox-OS | B2G/gecko/ipc/ipdl/ipdl/cgen.py | Python | apache-2.0 | 3,280 |
from bigml.api import BigML
api = BigML()
source1_file = "iris.csv"
args = \
{'fields': {'000000': {'name': 'sepal length', 'optype': 'numeric'},
'000001': {'name': 'sepal width', 'optype': 'numeric'},
'000002': {'name': 'petal length', 'optype': 'numeric'},
'000003': {'name': 'petal width', 'optype': 'numeric'},
'0000... | bigmlcom/bigmler | check_files/reify_anomaly_score.py | Python | apache-2.0 | 909 |
# (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
# Copyright 2017 Fujitsu 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/LICE... | openstack/python-monascaclient | monascaclient/client.py | Python | apache-2.0 | 5,352 |
# Copyright (C) 2013-2014 SignalFuse, Inc.
# Copyright (C) 2015 SignalFx, Inc.
#
# Docker container orchestration utility.
from __future__ import print_function
import functools
import sys
import threading
from . import tasks
from .. import audit
from .. import exceptions
from .. import termoutput
from ..termoutput ... | signalfuse/maestro-ng | maestro/plays/__init__.py | Python | apache-2.0 | 16,358 |
"""Utilities for extracting common archive formats"""
import zipfile
import tarfile
import os
import shutil
import posixpath
import contextlib
from distutils.errors import DistutilsError
if "__PEX_UNVENDORED__" in __import__("os").environ:
from pkg_resources import ensure_directory # vendor:skip
else:
from pex.t... | pantsbuild/pex | pex/vendor/_vendored/setuptools/setuptools/archive_util.py | Python | apache-2.0 | 6,730 |
#from configuration.manager import ConfigurationManager
#config = ConfigurationManager() | jmatthed/avatar-python | avatar/__init__.py | Python | apache-2.0 | 90 |
from beautifulsoup4 import beautifulsoup4
import re
def sanitize(html):
# allow these tags. Other tags are removed, but their child elements remain
whitelist = ['em', 'i', 'strong', 'u', 'a', 'b', 'p', 'br', 'code', 'pre', 'table', 'tr', 'td' ]
# allow only these attributes on these tags. No other tags ar... | fredzannarbor/pagekicker-community | scripts_python_3/bin/sanitize.py | Python | apache-2.0 | 2,661 |
# Copyright (c) 2018 PaddlePaddle 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 app... | luotao1/Paddle | python/paddle/fluid/tests/unittests/test_fusion_seqpool_cvm_concat_op.py | Python | apache-2.0 | 4,299 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# skyscanner documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
#
# 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
# ... | valery-barysok/skyscanner-python-sdk | docs/conf.py | Python | apache-2.0 | 8,466 |
# Copyright 2013 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 agre... | gaolichuang/py-essential | tests/testmods/fbar_foo_opt.py | Python | apache-2.0 | 719 |
import ujson
from django.http import HttpResponse
from mock import patch
from typing import Any, Dict
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.stream_topic import StreamTopicTarget
from zerver.models import (
get_realm,
get_stream,
get_stream_recipient,
get_user,
Recipie... | Galexrt/zulip | zerver/tests/test_muting.py | Python | apache-2.0 | 4,650 |
'''
Test the hsts response header.
'''
# 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, ... | dyrock/trafficserver | tests/gold_tests/headers/hsts.test.py | Python | apache-2.0 | 2,907 |
from django.conf.urls import url
from .views import OrderReturnView, StatusChangedNotificationView
urlpatterns = [
url(r'^return/$', OrderReturnView.as_view(), name='return_url'),
url(r'^update_order/$', StatusChangedNotificationView.as_view(), name='status_changed'),
]
| edoburu/django-oscar-docdata | oscar_docdata/urls.py | Python | apache-2.0 | 281 |
# 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, software
# d... | wolverineav/neutron | neutron/tests/unit/agent/l3/test_router_info.py | Python | apache-2.0 | 16,514 |
#
# 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... | dhalperi/beam | sdks/python/apache_beam/utils/urns.py | Python | apache-2.0 | 4,265 |
import pytest
from plenum.test.delayers import icDelay
from plenum.test.helper import checkViewNoForNodes
from plenum.test.node_catchup.helper import ensure_all_nodes_have_same_data
from plenum.test.stasher import delay_rules
from plenum.test.test_node import checkProtocolInstanceSetup
from plenum.test.view_change.hel... | evernym/plenum | plenum/test/view_change/test_no_future_view_change_while_view_change.py | Python | apache-2.0 | 1,825 |
from a10sdk.common.A10BaseClass import A10BaseClass
class Configure(A10BaseClass):
"""Class Description::
Configure sync Commands.
Class configure supports CRUD Operations and inherits from `common/A10BaseClass`.
This class is the `"PARENT"` class for this module.`
:param DeviceProxy: The d... | amwelch/a10sdk-python | a10sdk/core/configure/configure.py | Python | apache-2.0 | 818 |
from flask import Flask, request
from flask_restplus import Resource, Api, reqparse
from flask_jwt import JWT, jwt_required
from security import authenticate, identity
app = Flask(__name__)
app.secret_key = 'Wojciech'
api = Api(app)
# JWT creates a new endpoint /auth
jwt = JWT(app, authenticate, identity)
# List fo... | arcyfelix/Courses | 18-04-18-REST APIs with Flask and Python/Section 5 - Storing resources in a SQL database/2_Logging in and retrieving Users from a database/app.py | Python | apache-2.0 | 2,324 |
#!/usr/bin/env python
# ----------------------------------------------------------------------------
# Copyright 2015 Nervana Systems 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
#
# ... | nhynes/neon | examples/babi/train.py | Python | apache-2.0 | 4,049 |
# 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, software
# d... | queria/my-tempest | tempest/api/volume/test_volumes_snapshots.py | Python | apache-2.0 | 8,340 |
from vpp_interface import VppInterface
from vpp_papi import VppEnum
INDEX_INVALID = 0xffffffff
DEFAULT_PORT = 4789
UNDEFINED_PORT = 0
def find_vxlan_tunnel(test, src, dst, s_port, d_port, vni):
ts = test.vapi.vxlan_tunnel_v2_dump(INDEX_INVALID)
src_port = DEFAULT_PORT
if s_port != UNDEFINED_PORT:
... | FDio/vpp | test/vpp_vxlan_tunnel.py | Python | apache-2.0 | 3,138 |
# Copyright (c) 2021 PaddlePaddle 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 ap... | luotao1/Paddle | python/paddle/fluid/ir.py | Python | apache-2.0 | 22,516 |
import os
import ujson
import filecmp
import logging
from typing import Dict, Any, List
from zerver.lib.import_realm import (
do_import_realm,
)
from zerver.lib.test_classes import (
ZulipTestCase,
)
from zerver.data_import.mattermost_user import UserHandler
from zerver.data_import.mattermost import mattermo... | tommyip/zulip | zerver/tests/test_mattermost_importer.py | Python | apache-2.0 | 22,277 |
# Generated by Django 2.2rc1 on 2019-03-26 13:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('questions', '0042_remove_null_true'),
]
operations = [
migrations.AlterModelOptions(
name='catalog',
options={'ordering': (... | rdmorganiser/rdmo | rdmo/questions/migrations/0043_django2.py | Python | apache-2.0 | 1,023 |
# encoding: utf-8
# module _sre
# from (built-in)
# by generator 1.130
# no doc
# no imports
# Variables with simple values
CODESIZE = 4
copyright = ' SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB '
MAGIC = 20031017
# functions
def compile(*args, **kwargs): # real signature unknown
pass
def getcodesize... | akiokio/centralfitestoque | src/.pycharm_helpers/python_stubs/-1807332816/_sre.py | Python | bsd-2-clause | 453 |
# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# ------------------------------------------------... | biocore/qiita | qiita_db/test/test_util.py | Python | bsd-3-clause | 56,304 |
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
#
# All Plot3D vector functions
#
# Create the RenderWindow, Renderer and both Actors
#
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
ren1 = vtk.vtkRenderer()
... | hlzz/dotfiles | graphics/VTK-7.0.0/IO/Geometry/Testing/Python/Plot3DVectors.py | Python | bsd-3-clause | 3,828 |
#
# Collective Knowledge (compiler choices)
#
# See CK LICENSE.txt for licensing details
# See CK COPYRIGHT.txt for copyright details
#
# Developer: Grigori Fursin, Grigori.Fursin@cTuning.org, http://fursin.net
#
cfg={} # Will be updated by CK (meta description of this module)
work={} # Will be updated by CK (tempora... | ctuning/ck-autotuning | module/compiler/module.py | Python | bsd-3-clause | 28,151 |
from datetime import datetime, timedelta
from io import StringIO
import itertools
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
DataFrame,
Series,
Timestamp,
compat,
date_range,
option_context,
)
from pandas.core.arrays import IntervalArray, integer... | toobaz/pandas | pandas/tests/frame/test_block_internals.py | Python | bsd-3-clause | 22,034 |
import datetime
from django.conf import settings
from django.core.exceptions import FieldError
from django.db.backends.util import truncate_name
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query_utils import select_related_descend, QueryWrapper
from django.db.models.sql.constants import (SI... | makinacorpus/django | django/db/models/sql/compiler.py | Python | bsd-3-clause | 49,723 |
import hashlib
import mimetypes
import os
import posixpath
import re
from time import time
from urlparse import urlsplit, urlunsplit
from werkzeug.exceptions import NotFound
from werkzeug.http import is_resource_modified, http_date
from spa.static.handlers import StaticHandler
from spa.utils import clean_path
class... | pawpro/spa | spa/static/hashed.py | Python | bsd-3-clause | 8,271 |
import logging
from flask_babel import lazy_gettext
from .jsontools import dict_to_json
from .widgets import ChartWidget, DirectChartWidget
from ..baseviews import BaseModelView, expose
from ..models.group import DirectProcessData, GroupByProcessData
from ..security.decorators import has_access
from ..urltools import... | dpgaspar/Flask-AppBuilder | flask_appbuilder/charts/views.py | Python | bsd-3-clause | 17,665 |
import platform
from datetime import datetime
import pyexcel as pe
from flask import Flask, abort, jsonify, request
from flask_sqlalchemy import SQLAlchemy
import flask_excel as excel
app = Flask(__name__)
data = [[1, 2, 3], [4, 5, 6]]
if platform.python_implementation() == "PyPy":
app.config["SQLALCHEMY_DATAB... | chfw/Flask-Excel | tests/testapp.py | Python | bsd-3-clause | 4,610 |
#!/usr/bin/env python
"""Generate bibliography.rst
The input file is of the following form. Blank lines are ignored. New
lines are collapsed to a single space. Besides newlines, text for each
entry is copied without filtering, and thus reST syntax can be
used. Note that the key line must begin with '['.
[M55]
G. H. M... | necozay/tulip-control | doc/genbib.py | Python | bsd-3-clause | 1,618 |
# -*- coding: utf-8 -*-
"""
Bit Reading Request/Response messages
--------------------------------------
"""
import struct
from pymodbus3.pdu import ModbusRequest
from pymodbus3.pdu import ModbusResponse
from pymodbus3.pdu import ModbusExceptions
from pymodbus3.utilities import pack_bitstring, unpack_bitstring
clas... | gregorschatz/pymodbus3 | pymodbus3/bit_read_message.py | Python | bsd-3-clause | 8,239 |
# Copyright 2010, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the f... | pombreda/httpplus | httpplus/tests/test_bogus_responses.py | Python | bsd-3-clause | 2,832 |
# Copyright 2015 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.
import logging
import re
from telemetry.page import page as page_module
from telemetry.page import shared_page_state
from telemetry import story
from devil... | ds-hwang/chromium-crosswalk | tools/perf/page_sets/memory_health_story.py | Python | bsd-3-clause | 3,234 |
""" test parquet compat """
import datetime
from io import BytesIO
import os
import pathlib
from warnings import (
catch_warnings,
filterwarnings,
)
import numpy as np
import pytest
from pandas._config import get_option
from pandas.compat import is_platform_windows
from pandas.compat.pyarrow import (
pa_... | rs2/pandas | pandas/tests/io/test_parquet.py | Python | bsd-3-clause | 37,933 |
#! python
from carousel.core.data_sources import DataSource, DataParameter
from carousel.core.outputs import Output, OutputParameter
from carousel.core.formulas import Formula, FormulaParameter
from carousel.core.calculations import Calc, CalcParameter
from carousel.core.simulations import Simulation, SimParameter
fro... | mikofski/Carousel | examples/PythagoreanThm/pythagorean_thm.py | Python | bsd-3-clause | 2,570 |
"""
PASSIVE Plugin for Testing_for_SSL-TLS_(OWASP-CM-001)
"""
from framework.dependency_management.dependency_resolver import ServiceLocator
DESCRIPTION = "Third party resources"
def run(PluginInfo):
# Vuln search box to be built in core and resued in different plugins:
resource = ServiceLocator.get_compon... | DarKnight24/owtf | plugins/web/passive/Testing_for_SSL-TLS@OWTF-CM-001.py | Python | bsd-3-clause | 489 |
"""PgQ framework for Python."""
__pychecker__ = 'no-miximport'
import pgq.event
import pgq.consumer
import pgq.remoteconsumer
import pgq.producer
import pgq.status
import pgq.cascade
import pgq.cascade.nodeinfo
import pgq.cascade.admin
import pgq.cascade.consumer
import pgq.cascade.worker
from pgq.event import *
f... | overdrive3000/skytools | python/pgq/__init__.py | Python | isc | 980 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-10-26 08:11
from __future__ import unicode_literals
from django.db import migrations
import jsonfield.fields
def set_parameter(store, parameter):
"""Add parameter to the specified store."""
app, name = parameter.name.split(".")
if app not in sto... | tonioo/modoboa | modoboa/core/migrations/0010_auto_20161026_1011.py | Python | isc | 1,939 |
from __future__ import unicode_literals, division, absolute_import
from urlparse import urlparse
import logging
from requests import RequestException
from flexget import plugin
from flexget.event import event
from flexget.entry import Entry
log = logging.getLogger('sonarr')
class Sonarr(object):
schema = {
... | xfouloux/Flexget | flexget/plugins/input/sonarr.py | Python | mit | 5,907 |
# coding: utf-8
from mnist import MNIST
import math
import numpy as np
import itertools
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from random import randint
def get_np_array(path='data'):
"""
Get images and install converter:
1. install MNIST from the command line with 'pip insta... | mlhhu2017/identifyDigit | marc/mnist_util.py | Python | mit | 5,121 |
import socket
import datetime
import mock
from qpaca.monitoring.influx import InfluxDB
class TestInfluxDB(object):
@mock.patch('qpaca.monitoring.influx.InfluxDBClient')
def test_init(self, mocked_class):
client = InfluxDB(name='something', config={'client': {}})
assert mocked_class.called
... | WeLikeAlpacas/python-pubsub | tests/test_influxdb.py | Python | mit | 1,306 |
# -*- coding: utf-8 -*-
import numpy as np
from .red_blue import RedBlueMove
__all__ = ["DEMove"]
class DEMove(RedBlueMove):
r"""A proposal using differential evolution.
This `Differential evolution proposal
<http://www.stat.columbia.edu/~gelman/stuff_for_blog/cajo.pdf>`_ is
implemented following ... | joezuntz/emcee | src/emcee/moves/de.py | Python | mit | 1,581 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gevent.monkey; gevent.monkey.patch_all()
import gevent
import csv
import requests
import sys
def post_species(scientific, common, labels):
resp = requests.post('https://birdseye.space/v1/species', json={
'names': {
'scientific': scientific.l... | MihaiBalint/birdseye-server | test-data/species-import.py | Python | mit | 2,428 |
import re
import subprocess
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
from thefuck.shells import shell
@git_support
def match(command):
return ('did not match any file(s) known to git' in command.output
and "Did you forget to 'git... | SimenB/thefuck | thefuck/rules/git_checkout.py | Python | mit | 1,635 |
# A Turtle Block based on the Speak Activity interface to AIML
# Copyright 2012 Walter Bender, Sugar Labs
#
# Copyright (C) 2008 Sebastian Silva Fundacion FuenteLibre
# sebastian@fuentelibre.org
#
# Style and structure taken from Speak.activity Copyright (C) Joshua Minor
#
# HablarConSara.activity is free software:... | nvazquez/Turtlebots | pysamples/brain.py | Python | mit | 4,207 |
import pymysql.cursors
from pymysql.tests import base
from pymysql import util
from pymysql.err import ProgrammingError
import time
import datetime
__all__ = ["TestConversion", "TestCursor", "TestBulkInserts"]
class TestConversion(base.PyMySQLTestCase):
def test_datatypes(self):
""" test every data typ... | MonicaHsu/truvaluation | venv/lib/python2.7/site-packages/pymysql/tests/test_basic.py | Python | mit | 12,154 |
# What happens when a nested function is returned?
def fun1(param1):
local1 = param1 * 2
# A nested function.
def fun2(param2):
return param2 % local1
return fun2 # note the new return value
f = fun1(13)
print(f) # "<function fun2>"
# Before we execute f, think about the variables that it re... | DavidKMartel/Lectures | Python/Functions/closures.py | Python | mit | 559 |
# -*- coding: utf-8 -*-
## nodisplay
from scrapy.contrib.spiders import CrawlSpider
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.contrib.spiders import Rule
## /nodisplay
class WikiAraignee(CrawlSpider):
name = 'wiki1'
# Domaines autorisés lors du parcours du site.
# Les UR... | datapublica/scrapython | examples/scrapy/scrapy_example/spiders/wiki1.py | Python | mit | 733 |
import numpy as np
from keras import backend as K
all_metrics = []
all_sparse_metrics = []
def validate_metric(metric):
y_a = K.variable(np.random.random((6, 7)))
y_b = K.variable(np.random.random((6, 7)))
output = metric(y_a, y_b)
assert K.eval(output).shape == ()
| farizrahman4u/keras-contrib | keras_contrib/tests/metrics.py | Python | mit | 286 |
# View more python learning tutorial on my Youtube and Youku channel!!!
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
# Youku video tutorial: http://i.youku.com/pythontutorial
import tkinter as tk
window = tk.Tk()
window.title('my window')
window.geometry('200x200')
l = tk.Label... | wangwei7175878/tutorials | tkinterTUT/tk6_scale.py | Python | mit | 643 |
# Dummy calls for representing openings
def pgmtoppm(atlas_slice):
result = atlas_slice[:-3] + "ppm"
with open(atlas_slice, "rb") as aslice, \
open(result, "w") as gif:
gif.write(atlas_slice + ".ppm")
return result
def pnmtojpeg(ppm_slice):
result = ppm_slice[:-3] + "jpg"
with ... | gems-uff/noworkflow | capture/noworkflow/resources/demo/2016_ipaw_paper/step4/convert.py | Python | mit | 449 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Zeyuan Shang
# @Date: 2015-12-01 01:05:22
# @Last Modified by: Zeyuan Shang
# @Last Modified time: 2015-12-01 01:05:37
import heapq
class MedianFinder:
def __init__(self):
"""
Initialize your data structure here.
"""
self.... | EdisonAlgorithms/HackerRank | practice/data-structures/heap/find-median-1/find-median-1.py | Python | mit | 1,239 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com thumbor@googlegroups.com
import cv2
import numpy as np
from thumbor.detectors import BaseDet... | okor/thumbor | thumbor/detectors/feature_detector/__init__.py | Python | mit | 1,356 |
# -*- coding:utf-8 -*-
"""
一些能够帮你提升效率的辅助函数
"""
from __future__ import unicode_literals, division
from copy import deepcopy
from datetime import timedelta
from threading import Thread
import requests
import requests.exceptions
from six.moves import urllib
from .log import logger
from .value import ENV
__all__ = ['ge... | er1iang/hfut_stu_lib | hfut/util.py | Python | mit | 8,546 |
"""
Process thrasher
"""
import logging
import gevent
import random
import time
from teuthology.orchestra import run
log = logging.getLogger(__name__)
class ProcThrasher:
""" Kills and restarts some number of the specified process on the specified
remote
"""
def __init__(self, config, remote, *pr... | SUSE/teuthology | teuthology/task/proc_thrasher.py | Python | mit | 2,404 |
import random
def run(data, settings):
if data['payload'] == 'goat thrower':
if random.randint(0, 110) == 0:
outcome = random.randint(0, 2)
if outcome == 0:
return "{nick}: The goat thrower engulfs you in a billowing wave of goat. Goats swim over your body as they re... | kyleterry/tenyks-contrib | src/tenyksscripts/scripts/goatthrower.py | Python | mit | 1,487 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#==============================================================================
# Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Amazon Software License (the "License"). You may not use
# this file except in compliance with th... | coen-hyde/dotfiles | libs/eb/scli/constants.py | Python | mit | 21,046 |
#!/usr/bin/env python
import sys
import os
import urllib
import json
import re
from models import *
from ApiClient import ApiException
class TasksApi(object):
def __init__(self, apiClient):
self.apiClient = apiClient
def DeleteProjectAssignment(self, name, assignmentUid, **kwargs):
"""D... | sohail-aspose/Aspose_Tasks_Cloud | SDKs/Aspose.Tasks_Cloud_SDK_for_Python/asposetaskscloud/TasksApi.py | Python | mit | 143,735 |
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# Entry-type module for blobs, which are binary objects read from files
#
from binman.entry import Entry
from dtoc import fdt_util
from patman import tools
from patman import tout
class Entry_blob(Entry)... | Digilent/u-boot-digilent | tools/binman/etype/blob.py | Python | gpl-2.0 | 2,472 |
# -*- coding: utf-8 -*-
""" The expression editor present in some locations of CFME.
"""
from functools import partial
from selenium.common.exceptions import NoSuchElementException
from cfme.utils.wait import wait_for, TimedOutError
import re
from cfme.utils.pretty import Pretty
from widgetastic_patternfly import Inp... | akarol/cfme_tests | widgetastic_manageiq/expression_editor.py | Python | gpl-2.0 | 17,213 |
# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences
# Copyright (C) 2012 - 2017 by the BurnMan team, released under the GNU
# GPL v2 or later.
from __future__ import absolute_import
import numpy as np
from .material import Material
from .averaging_schemes im... | CaymanUnterborn/burnman | burnman/model.py | Python | gpl-2.0 | 6,155 |
# package.py
# Module defining the dnf.Package class.
#
# Copyright (C) 2012-2013 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... | rholy/dnf | dnf/package.py | Python | gpl-2.0 | 6,052 |
"""
SALTS XBMC Addon
Copyright (C) 2016 tknorris
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 3 of the License, or
(at your option) any later version.
T... | felipenaselva/repo.felipe | plugin.video.salts/salts_lib/worker_pool.py | Python | gpl-2.0 | 4,999 |
#!/usr/bin/env python
import roslib; roslib.load_manifest('rviz')
import sys
#setattr(sys, 'SELECT_QT_BINDING', 'pyside') # Shiboken
setattr(sys, 'SELECT_QT_BINDING', 'pyqt') # SIP
import python_qt_binding.QtBindingHelper # @UnusedImport
from QtGui import *
from QtCore import *
import rviz
c = rviz.Config()
c.mapSet... | olivierdm/rviz | src/test/config_sample.py | Python | gpl-2.0 | 2,859 |
from test import test_support
import unittest
nis = test_support.import_module('nis')
class NisTests(unittest.TestCase):
def test_maps(self):
try:
maps = nis.maps()
except nis.error, msg:
# NIS is probably not active, so this test isn't useful
self.sk... | j5shi/Thruster | pylibs/test/test_nis.py | Python | gpl-2.0 | 1,215 |
#!/usr/bin/python
# must be started in the npc dir
import os
import re
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False,
help="show the occurrences of that var")
parser.add_option("-f", "--file", dest=... | TheManaWorld-Ger/server-data | tools/showvars.py | Python | gpl-2.0 | 2,535 |
#!/usr/bin/env python
'''
Copyright (C) 2007 John Beard john.j.beard@gmail.com
##This extension allows you to draw a Cartesian grid in Inkscape.
##There is a wide range of options including subdivision, subsubdivions
## and logarithmic scales. Custom line widths are also possible.
##All elements are grouped with simi... | piksels-and-lines-orchestra/inkscape | share/extensions/grid_cartesian.py | Python | gpl-2.0 | 14,264 |
# Copyright (c) 2016 Czech National Corpus
#
# 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; version 2
# dated June, 1991.
#
# This program is distributed in the hope that it will be useful,
# b... | tomachalek/kontext | lib/mailing.py | Python | gpl-2.0 | 2,086 |
# Copyright (C) 2015 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the f... | Debian/openjfx | modules/web/src/main/native/Tools/Scripts/webkitpy/benchmark_runner/benchmark_results_unittest.py | Python | gpl-2.0 | 16,571 |
###############################################################################
# Name: kix.py #
# Purpose: Syntax configuration module for KIXtart scripts #
# Author: Cody Precord <cprecord@editra.org> #
... | garrettcap/Bulletproof-Backup | wx/tools/Editra/src/syntax/_kix.py | Python | gpl-2.0 | 4,682 |
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 9 11:10:56 2014
@author: MasterMac
"""
sec = int(raw_input())
hour = sec / 60**2
minute = sec / 60 % 60
second = sec % 60
print hour, minute, second
| hacpai/show-me-the-code | Python/0002/main.py | Python | gpl-2.0 | 202 |
# -*- coding: utf-8 -*-
#
# This file is part of INSPIRE.
# Copyright (C) 2014-2017 CERN.
#
# INSPIRE 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 ... | Glignos/inspire-next | inspirehep/alembic/cb5153afd839_create_workflow_record_sources_table.py | Python | gpl-3.0 | 2,055 |
#
# THIS IS WORK IN PROGRESS
#
# The Python Imaging Library
# $Id: PcfFontFile.py 2134 2004-10-06 08:55:20Z fredrik $
#
# portable compiled font file parser
#
# history:
# 1997-08-19 fl created
# 2003-09-13 fl fixed loading of unicode fonts
#
# Copyright (c) 1997-2003 by Secret Labs AB.
# Copyright (c)... | KAMI911/loec | examples/Sharpen/binaries-windows-python26/PcfFontFile.py | Python | gpl-3.0 | 6,642 |
# Copyright (C) 2010-2014 GRNET S.A.
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed i... | olgabrani/synnefo | snf-tools/synnefo_tools/burnin/cyclades_common.py | Python | gpl-3.0 | 30,688 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import locale
import os
import sys
from datetime import date
from kargoxml import add_column
script_dir = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
project_dir = os.path.split(script_dir)[0]
sys.path.append(project_dir)
sys.path.append(os.path.split(projec... | MehmetNuri/ozgurlukicin | scripts/kargo/main.py | Python | gpl-3.0 | 1,129 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# 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 3 of the Licen... | oliver-sanders/cylc | cylc/flow/flow_mgr.py | Python | gpl-3.0 | 2,831 |
# -*- coding: UTF-8 -*-
# Phatch - Photo Batch Processor
# Copyright (C) 2007-2008 www.stani.be
#
# 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 3 of the License, or
# (at your ... | anish/phatch | phatch/data/info.py | Python | gpl-3.0 | 16,717 |
#!/usr/bin/env python -t
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Jonathan Delvaux <pyshell@djoproject.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 version 3 of the License... | djoproject/pyshell | pyshell/utils/key.py | Python | gpl-3.0 | 5,081 |
from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.loader import Loader
from couchpotato.core.settings import Settings
from sqlalchemy.engine import create_engine
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm.session import sessionmaker
import os
class Env(object):
_appna... | arnif/CouchPotatoServer | couchpotato/environment.py | Python | gpl-3.0 | 3,124 |
from functools import partial
from sympy.strategies import chain, minimize
import sympy.strategies.branch as branch
from sympy.strategies.branch import yieldify
identity = lambda x: x
def treeapply(tree, join, leaf=identity):
""" Apply functions onto recursive containers (tree)
join - a dictionary mapping co... | lidavidm/mathics-heroku | venv/lib/python2.7/site-packages/sympy/strategies/tree.py | Python | gpl-3.0 | 3,710 |
from scipy import *
from scipy.integrate import simps
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def Compute_Aw(om, DOS, Sig, ommesh, delta=0.1j):
Aw = zeros(len(om))
for i in range(len(om)):
DMFTW = DOS / (om[i] - Sig[i] - ommesh + delta)
Aw[i] = simps(-1.*DMFTW.imag/pi, omme... | slek120/phys534 | HW4/194287.admin.extreme.uic.edu/spectral_function.py | Python | gpl-3.0 | 895 |
import urllib,urllib2,re,cookielib,os,sys
import xbmc, xbmcgui, xbmcaddon, xbmcplugin
from resources.libs import main
#Mash Up - by Mash2k3 2012.
from t0mm0.common.addon import Addon
from resources.universal import playbackengine, watchhistory
addon_id = 'plugin.video.movie25'
selfAddon = xbmcaddon.Addon(id=addon_id)... | marduk191/plugin.video.movie25 | resources/libs/adventure/nationalgeo.py | Python | gpl-3.0 | 11,061 |
from sympy.utilities.pytest import XFAIL, raises
from sympy import (symbols, lambdify, sqrt, sin, cos, pi, atan, Rational, Float,
Matrix, Lambda, exp, Integral, oo, I)
from sympy.printing.lambdarepr import LambdaPrinter
from sympy import mpmath
from sympy.utilities.lambdify import implemented_function
import ma... | GbalsaC/bitnamiP | venv/lib/python2.7/site-packages/sympy/utilities/tests/test_lambdify.py | Python | agpl-3.0 | 11,262 |
"""
Tests for the LMS compatibility mixin for the OpenAssessment block.
"""
from ddt import ddt
from .base import XBlockHandlerTestCase, scenario
@ddt
class LmsMixinTest(XBlockHandlerTestCase):
"""Test the simple LMS-specific attributes used during grading."""
@scenario('data/basic_scenario.xml')
def te... | Stanford-Online/edx-ora2 | openassessment/xblock/test/test_lms.py | Python | agpl-3.0 | 777 |
from .views import ImageCRUDL
urlpatterns = ImageCRUDL().as_urlpatterns() | eHealthAfrica/ureport | ureport/assets/urls.py | Python | agpl-3.0 | 74 |
from __future__ import unicode_literals
from django.apps import AppConfig
class LoanConfig(AppConfig):
name = 'loan'
| Fshem/micro_bank_system | loan/apps.py | Python | agpl-3.0 | 124 |
# -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2017, Shoop Commerce Ltd. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
from shuup.apps import AppConfig
class ShuupNotifyAppConfig(App... | suutari-ai/shoop | shuup/notify/__init__.py | Python | agpl-3.0 | 1,215 |