text stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 231 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k | score float64 0 0.34 |
|---|---|---|---|---|---|---|
#!/usr/bin/env python
# GoodFET SPI and SPIFlash Client Library
#
# (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
#
# This code is being rewritten and refactored. You've been warned!
import sys, time, string, cStringIO, struct, glob, os;
from GoodFET import GoodFET;
class GoodFETAVR(GoodFET):
AVRAP... | rfmcpherson/killerbee | killerbee/GoodFETAVR.py | Python | bsd-3-clause | 5,235 | 0.025788 |
class Hayvan:
def __init__(self,isim, renk):
self.isim=isim
self.renk=renk
def yuru(self):
print(self.isim+" yurumeye basladi")
def ye(self):
print(self.isim+" yemeye basladi")
class Fare(Hayvan):
def __init__(self,isim,renk):
super().__init__(isim,ren... | zinderud/ysa | python/first/inheritance.py | Python | apache-2.0 | 468 | 0.027778 |
#!/usr/bin/python
from pyliferisk import MortalityTable
from pyliferisk.mortalitytables import GKM95
import numpy as np
mt = MortalityTable(nt=GKM95)
x = 40 #age
n = 20 #horizon
C = 10000 #capital
i = 0.03 #interest rate
payments = []
for t in range(0,n):
payments.append((mt.lx[x+t] - mt.lx[x+t+1]) / mt.lx[x]... | franciscogarate/pyliferisk | Examples/Example_2_2_3b.py | Python | gpl-3.0 | 608 | 0.021382 |
import os
import functools
import logging
import six
from pelican.utils import (slugify, python_2_unicode_compatible)
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
@functools.total_ordering
class URLWrapper(object):
def __init__(self, name, settings):
# next 2 lines are redundant wi... | 0xMF/pelican | pelican/urlwrappers.py | Python | agpl-3.0 | 2,731 | 0 |
# -*- coding:utf-8 -*-
from urllib.parse import urlparse
from lxml import html
from lxml.html.clean import Cleaner
from .forms import FormWrapper
from .helpers import (
match_form,
filter_element
)
class HtmlParser:
""" Parses response content string to valid html using `lxml.html`
"""
def __i... | nuncjo/Delver | delver/parser.py | Python | mit | 2,824 | 0.001416 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-29 13:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("issuetracker", "0004_data_migration_set_bugzilla_to_allow_add_case_to_issue"),
]
operations = [
migrations.RemoveFi... | Nitrate/Nitrate | src/tcms/issuetracker/migrations/0005_adjust_issue_report_fields.py | Python | gpl-2.0 | 1,490 | 0.002013 |
from firebase import firebase
from flask import request
from flask.ext.restful import Resource
class BaseAlert(Resource):
db = firebase.FirebaseApplication(
dsn='https://stockdelta.firebaseio.com/',
authentication=None)
class Alerts(BaseAlert):
def get(self):
result = self.db.get(url... | kienpham2000/stockdelta-api | stockdelta/api/alerts.py | Python | mit | 717 | 0 |
# -*- coding: utf-8 -*-
#
# 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 have a default; values that are commented out
# serve to show the default.
import os
impo... | wireservice/agate-excel | docs/conf.py | Python | mit | 7,310 | 0.006156 |
../../../../../share/pyshared/papyon/sip/call_manager.py | Alberto-Beralix/Beralix | i386-squashfs-root/usr/lib/python2.7/dist-packages/papyon/sip/call_manager.py | Python | gpl-3.0 | 56 | 0.017857 |
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
import mozdevice
import mozlog
import unittest
from sut import MockAgent
class MkDirsTest(unittest.TestCase):
def test_mkdirs(self):
subTests = [{'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'),
... | michath/ConMonkey | testing/mozbase/mozdevice/tests/sut_mkdir.py | Python | mpl-2.0 | 2,854 | 0.001051 |
"""
Zorp serialiser
"""
from bson import BSON
class Serialiser(object):
"""
This is simply a wrapper for the bson encoder/decoder
that can deal with non-dict types
"""
WRAPPER = "data"
@staticmethod
def encode(obj):
"""
Wrap the object in a dict and bson encode it
... | proxama/zorp | zorp/serialiser.py | Python | mit | 566 | 0.001767 |
#!/usr/bin/env python3
import os
from settings import JSONDIR, logging
from defs import load_data, dump_data
def sort_storage_records(records, sorted_systems):
try:
records.sort(key=lambda x: sorted_systems.index(x['Storage']))
except:
pass
return records
def sum_3par():
capD = {}
... | tulsluper/sanscript | apps/da/scripts/form_capacity.py | Python | gpl-3.0 | 6,110 | 0.002782 |
#!/usr/bin/env python
#
# Copyright (c) 2016, The OpenThread Authors.
# 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
# notic... | openthread/openthread | tools/harness-automation/cases_R140/router_5_5_2.py | Python | bsd-3-clause | 1,876 | 0 |
#!/usr/bin/env python
"""
pymonitoringapi example script to find the server type
and version of our monitoring server.
"""
import optparse
import sys
import os
import pprint
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")))
from pymonitoringapi import MonitoringAPI
V... | jantman/pymonitoringapi | examples/get_service_status.py | Python | lgpl-3.0 | 2,213 | 0.003615 |
#
# Copyright (c) 2010-2011, Nick Blundell
# 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 cond... | blundeln/pylens | scripts/generate_docs.py | Python | bsd-3-clause | 5,581 | 0.023114 |
# Copyright 2017 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, ... | googleapis/google-resumable-media-python | google/_async_resumable_media/_upload.py | Python | apache-2.0 | 37,337 | 0.000214 |
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--bucket", help="bucket for input and output")
args = parser.parse_args()
BUCKET = args.bucket
from pyspark.sql import SparkSession, SQLContext, Row
spark = SparkSession.builder.appName("kdd").getOrCreate()
sc = spark.sparkContext
data_file = "g... | GoogleCloudPlatform/training-data-analyst | quests/sparktobq/spark_analysis.py | Python | apache-2.0 | 2,849 | 0.004563 |
"""
Support for ZoneMinder Sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.zoneminder/
"""
import logging
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import STATE_UNKNOWN
... | MungoRae/home-assistant | homeassistant/components/sensor/zoneminder.py | Python | apache-2.0 | 3,361 | 0 |
#!/usr/bin/env python3
#
# (c) Christian Sommerfeldt OEien
# All rights reserved
from rmg.color import Color, InkColor, white_ink
from rmg.board import Photo, Image, Board
from rmg.plane import XY
from argparse import ArgumentParser
from sys import stderr
from math import sqrt, floor
from copy import copy
... | biotty/rmg | graphics/py/posterize.py | Python | bsd-2-clause | 3,589 | 0.002229 |
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Side by side diffs
@copyright: 2002 Juergen Hermann <jh@web.de>,
2002 Scott Moonen <smoonen@andstuff.org>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.support import difflib
from MoinMoin.wikiutil import escape
def i... | Glottotopia/aagd | moin/local/moin/build/lib.linux-x86_64-2.6/MoinMoin/util/diff_html.py | Python | mit | 5,991 | 0.00434 |
from .base_client import GoogleBaseClient
class GoogleIAmClient(GoogleBaseClient):
def __init__(self, project, **kwargs):
super().__init__(f'https://iam.googleapis.com/v1/projects/{project}', **kwargs)
# https://cloud.google.com/iam/docs/reference/rest
| hail-is/hail | hail/python/hailtop/aiocloud/aiogoogle/client/iam_client.py | Python | mit | 272 | 0.003676 |
'''
The Core of peterhellberg
'''
import requests
from . import metadata
def parse(url, use_ssl=False):
'''Send a http request to the remote server
Return the response, as a dictionary
Raises requests.exceptions.ConnectionError in event of a network error
Raises requests.exceptions.HTTPError in even... | forfuturellc/peterhellberg | peterhellberg/main.py | Python | mit | 1,258 | 0.000795 |
import pytest
from conftest import is_bash_type
@pytest.mark.bashcomp(
pre_cmds=("CLASSPATH=$PWD/java/a:$PWD/java/bashcomp.jar",)
)
class TestJava:
@pytest.fixture(scope="class")
def can_list_jar(self, bash):
return (
is_bash_type(bash, "zipinfo")
or is_bash_type(bash, "un... | algorythmic/bash-completion | test/t/test_java.py | Python | gpl-2.0 | 1,508 | 0 |
#
# SelfTest/Util/test_strxor.py: Self-test for XORing
#
# ===================================================================
#
# Copyright (c) 2014, Legrandin <helderijs@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided tha... | cloudera/hue | desktop/core/ext-py/pycryptodomex-3.9.7/lib/Cryptodome/SelfTest/Util/test_strxor.py | Python | apache-2.0 | 10,618 | 0.00292 |
# -*- coding: utf-8 -*-
import os
import sys
import math
from pathlib import Path
import scipy.misc
import h5py
import numpy as np
import tensorflow as tf
import torch
import torch.nn as nn
import click
from models.slim.nets.inception_resnet_v2 import (
inception_resnet_v2,
inception_resnet_v2_arg_scope)
sl... | smly/nips17_adversarial_attack | defense/import_from_tf_baseline/dump_ens_adv_inception_resnet_v2.py | Python | apache-2.0 | 30,348 | 0 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import mysql.connector
import datetime
HEADER_TEMPLATE = \
"HTTP/1.1 200 OK\r\n" \
"Server: webhttpd/2.0\r\n" \
"Cache-Control: no-cache, no-store, must-revalidate\r\n" \
"Connection: keep-alive\r\n" \
"Content-Type: text/html; charset=utf-8\r\n" \
... | eamars/webserver | site-package/index2.py | Python | mit | 3,741 | 0.00294 |
"""
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
https://leetcode.com/problems/is-subsequence/
Date: 10/29/21
"""
def is_seq(s,t):
ls = list(s)
lt = list(t)
idx = []
for e in ls:
if e in lt:
idx.append(lt.index(e))
if len(idx)>1... | entrepidea/projects | python/tutorials/algo/leetcode/easy/is_sebsequence.py | Python | gpl-3.0 | 641 | 0.014041 |
#:coding=utf-8:
from django.test import TestCase as DjangoTestCase
from django.forms import Form
from beproud.django.commons.forms import EmailField
__all__ = (
'EmailFieldTest',
'JSONFormFieldTest',
'JSONWidgetTest',
)
class EmailTestForm(Form):
email = EmailField(label="email")
class EmailFiel... | beproud/bpcommons | tests/test_forms_field.py | Python | bsd-2-clause | 1,310 | 0.00229 |
def power_digit_sum(exponent):
power_of_2 = str(2 ** exponent)
return sum([int(x) for x in power_of_2]) | plilja/project-euler | problem_16/power_digit_sum.py | Python | apache-2.0 | 111 | 0.009009 |
# -*- python -*-
# Git Version: @git@
#-----------------------------------------------------------------------
# XALT: A tool that tracks users jobs and environments on a cluster.
# Copyright (C) 2013-2014 University of Texas at Austin
# Copyright (C) 2013-2014 University of Tennessee
#
# This library is free softwar... | xalt/xalt | proj_mgmt/py_build_tools/build_python_filter_routine.py | Python | lgpl-2.1 | 3,443 | 0.01946 |
# -*- coding: utf-8 -*-
## This file is part of Invenio.
## Copyright (C) 2012, 2013 CERN.
##
## 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 (at your option... | lnielsen/invenio | invenio/ext/babel/selectors.py | Python | gpl-2.0 | 2,593 | 0.00887 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU... | OpusVL/odoo | addons/stock/wizard/make_procurement_product.py | Python | agpl-3.0 | 5,960 | 0.003859 |
# coding=utf-8
import os
import subliminal
import base64
import zlib
from subliminal import __short_version__
from subliminal.refiners.omdb import OMDBClient, refine as refine_orig, Episode, Movie
from subliminal_patch.http import TimeoutSession
class SZOMDBClient(OMDBClient):
def __init__(self, version=1, sessio... | dantebarba/docker-media-server | plex/Sub-Zero.bundle/Contents/Libraries/Shared/subliminal_patch/refiners/omdb.py | Python | gpl-3.0 | 2,505 | 0.001597 |
"""
Copyright (c) 2016 Jet Propulsion Laboratory,
California Institute of Technology. All rights reserved
"""
import json
import unittest
import urllib
from multiprocessing.pool import ThreadPool
from unittest import skip
import numpy as np
from mock import Mock
from nexustiles.model.nexusmodel import Tile, BBox
from... | dataplumber/nexus | analysis/tests/algorithms/StandardDeviationSearch_test.py | Python | apache-2.0 | 9,139 | 0.002954 |
#!/usr/bin/env python
"""
{'friendly_name': '',
'string_id': '',
'css_selector': ''},
"""
elements = [
{'friendly_name': 'Golden Tickets',
'string_id': 'magic-tickets',
'css_selector': '#magic-tickets'},
{'friendly_name': 'Marvels Await Poster',
'string_id': 'marve... | mozilla/webowonder | bin/generate_l10n_css_overides.py | Python | bsd-3-clause | 1,931 | 0.00725 |
# -*- coding: utf-8 -*-
"""
werkzeug.wrappers
~~~~~~~~~~~~~~~~~
The wrappers are simple request and response objects which you can
subclass to do whatever you want them to do. The request object contains
the information transmitted by the client (webbrowser) and the response
object contains al... | mrdon/flask | werkzeug/wrappers.py | Python | bsd-3-clause | 76,207 | 0.000276 |
from __future__ import annotations
import random
import pytest
import scitbx.matrix
from cctbx import sgtbx
from cctbx.sgtbx import bravais_types
from dials.algorithms.indexing.max_cell import find_max_cell
from dials.array_family import flex
@pytest.fixture(params=bravais_types.acentric)
def setup(request):
... | dials/dials | tests/algorithms/indexing/test_max_cell.py | Python | bsd-3-clause | 2,598 | 0.001155 |
########################################################################
#
# File: label.py
# Author: Alex Samuel
# Date: 2001-03-17
#
# Contents:
# Label
#
# Copyright (c) 2001, 2002 by CodeSourcery, LLC. All rights reserved.
#
# For license terms see the file COPYING.
#
#######################################... | stefanseefeld/qmtest | qm/label.py | Python | gpl-2.0 | 6,102 | 0.003933 |
"""
frontend_auth is a wrapper around the `django.contrib.auth.view` Views.
* **templates/** Contains the templates for login / pw change / pw reset views and the password_reset emails
* **auth_mixins.py** Provides a simple mixin that tests if `instance.agency == request.user.agencyemployee.agency`, more to come
... | phelmig/outside_ | mvp/outside/frontend_auth/__init__.py | Python | mit | 1,006 | 0.006958 |
# Copyright 2016 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | HewlettPackard/python-proliant-sdk | examples/Redfish/ex31_set_license_key.py | Python | apache-2.0 | 2,431 | 0.014809 |
# 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 u... | jasonstack/cassandra | pylib/cqlshlib/cqlshhandling.py | Python | apache-2.0 | 10,355 | 0.001545 |
# -*- coding: utf-8 -*-
"""
Internationalization facilities
Authors: David Malcolm <dmalcolm@redhat.com>
"""
__author__ = """David Malcolm <dmalcolm@redhat.com>, Zack Cerza <zcerza@redhat.com>"""
import config
import os
import re
import gettext
from logging import debugLogger as logger
from __builtin__ import unic... | vrutkovs/dogtail | dogtail/i18n.py | Python | gpl-2.0 | 10,076 | 0.002084 |
var = 2
start = 1
last = 1
while(len(str(start)) < 1000):
var=var+1
temp = start
start = start+last
last = temp
print("Final: " + str(var))
| DarrenBellew/CloudCompDT228-3 | Lab3/1000FibNumber.py | Python | mit | 158 | 0.006329 |
#!/usr/bin/env python3
#
#
# copyright Kevin Walchko
#
# Basically a rostopic
from __future__ import print_function
import argparse
import time
# from pygecko import TopicSub
from pygecko.transport import zmqTCP, GeckoCore
from pygecko.multiprocessing import GeckoPy
from pygecko.test import GeckoSimpleProcess
# from ... | walchko/pygecko | dev/services/test.py | Python | mit | 1,384 | 0.001445 |
class NoResultsException(Exception):
def __init__(self):
Exception("No Results.")
class RelationalOperator(object):
def __init__(self, parent):
self.parent = parent
def GenSql(self, sqlBuilder):
"""
Main external interface for SQL generation.
The client co... | alcides/rdflib | rdflib/sparql/sql/RelationalOperators.py | Python | bsd-3-clause | 4,107 | 0.012661 |
# -*- coding: utf-8 -*-
def toflat(obj, ns=""):
res = {}
for key in obj:
if type(obj[key]) is dict:
subdict = toflat(obj[key], "%s%s" % (ns,key[0].upper()+key[1:]))
for k in subdict:
res[k[0].upper()+k[1:]] = subdict[k]
else:
res["%s%s" % (n... | fraoustin/flask-monitor | flask_monitor/util.py | Python | gpl-2.0 | 634 | 0.015773 |
#!/usr/bin/env python
#
# Python Serial Port Extension for Win32, Linux, BSD, Jython
# module for serial IO for POSIX compatible systems, like Linux
# see __init__.py
#
# (C) 2001-2010 Chris Liechti <cliechti@gmx.net>
# this is distributed under a free software license, see license.txt
#
# parts based on code from Gran... | lucastanure/GoGo-Real-Software | core/communication/serial/serialposix.py | Python | gpl-3.0 | 25,395 | 0.005828 |
#
# 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... | markflyhigh/incubator-beam | sdks/python/apache_beam/options/pipeline_options_validator_test.py | Python | apache-2.0 | 12,764 | 0.005719 |
import os
import numpy as np
import pytest
from pandas import (
Categorical,
DatetimeIndex,
Interval,
IntervalIndex,
NaT,
Series,
TimedeltaIndex,
Timestamp,
cut,
date_range,
isna,
qcut,
timedelta_range,
)
from pandas.api.types import CategoricalDtype as CDT
from pan... | toobaz/pandas | pandas/tests/reshape/test_qcut.py | Python | bsd-3-clause | 6,328 | 0.000474 |
#!/usr/bin/env python
# Python 3 required
# THIS TAKES WAAAAY TO LONG. ONLY SOLVED IT BY LETTING IT RUN
# OVERNIGHT ACCIDENTALLY :/
import locale
import sys
import math
import timeit
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59... | jarretraim/euler_py | 1-10/03.py | Python | apache-2.0 | 1,446 | 0.040111 |
import os
import click
from benchmark import option_simulation
import devito
@click.group()
def menu():
pass
@menu.command(name='generate')
@option_simulation
@click.option('-nn', multiple=True, default=[1], help='Number of nodes')
@click.option('-ncpus', default=1, help='Number of cores *per node*') # Shoul... | opesci/devito | benchmarks/user/make-pbs.py | Python | mit | 2,496 | 0.002404 |
# Python standard library
from os import path, listdir
from ConfigParser import ConfigParser
# Third-party libraries
from imagecraft import ImageGenerator
# Django settings
from django.conf import settings
# This module
from cleaver import ini_to_context, flatten_context
# Retrieve execution params
MEDIA_ROOT = g... | isolationism/django-cleaver | django_cleaver/imagecreator.py | Python | bsd-3-clause | 2,540 | 0.001575 |
#!/usr/bin/env python
############################################################
# ConfigScanner - A buildbot config scanner and updater #
# Also does ReviewBoard (and at some point Bugzilla?) #
# Built for Python 3, works with 2.7 with a few tweaks #
#####################################################... | chtyim/infrastructure-puppet | modules/buildbot_asf/files/configscanner.py | Python | apache-2.0 | 12,920 | 0.016718 |
__author__ = "John Kirkham <kirkhamj@janelia.hhmi.org>"
__date__ = "$Mar 30, 2015 08:25:33 EDT$"
import collections
import json
import os
import os.path
import shutil
import tempfile
import numpy
import h5py
import vigra
import vigra.impex
import nanshe.util.iters
import nanshe.util.xnumpy
import nanshe.io.xtiff
... | DudLab/nanshe | tests/test_nanshe/test_converter.py | Python | bsd-3-clause | 2,908 | 0.005158 |
# 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... | alexandrucoman/vbox-neutron-agent | neutron/tests/unit/plugins/sriovnicagent/test_pci_lib.py | Python | apache-2.0 | 4,204 | 0 |
#!/usr/bin/env python
# Copyright (c) 2015, Robot Control and Pattern Recognition Group,
# Institute of Control and Computation Engineering
# Warsaw University of Technology
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the ... | dseredyn/velma_scripts | scripts/test_hierarchy_control.py | Python | bsd-3-clause | 18,738 | 0.007792 |
import logging, os
from autotest_lib.client.common_lib import error
from autotest_lib.client.bin import utils
def run_clock_getres(test, params, env):
"""
Verify if guests using kvm-clock as the time source have a sane clock
resolution.
@param test: kvm test object.
@param params: Dictionary with... | libvirt/autotest | client/virt/tests/clock_getres.py | Python | gpl-2.0 | 1,155 | 0.000866 |
'''
Given a number of integer intervals, collapse them:
Input: [(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)]
Output: [(0, 1), (3, 8), (9, 12)]
'''
def collapse_range(slots):
# order based on the first slot
ordered_slots = sorted(slots, key=lambda range: range[0])
merged_slots = []
i = 0
j = 0
... | amitsaha/learning | python/collapse_range.py | Python | unlicense | 1,067 | 0.004686 |
#!/usr/bin/python
def app(environ, start_response):
request = environ['QUERY_STRING']
start_response("200 OK", [
("Content-Type", "text/plain"),
])
return [request.replace('&','\n') ]
| smartybit/stepic_webtech1 | web/hello.py | Python | mit | 221 | 0.027149 |
#!/usr/bin/env python
#############################################################################
##
## Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
## Contact: http://www.qt-project.org/legal
##
## This file is part of the test suite of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:LGPL$
## Commercial License... | RLovelett/qt | doc/src/diagrams/contentspropagation/customwidget.py | Python | lgpl-2.1 | 6,694 | 0.007619 |
from django.conf.urls import include, url
from django.views.generic import TemplateView
urlpatterns = [
url(r"^home/", TemplateView.as_view(template_name="no-ie.html"), name="home"),
url(r"^", include("formly.urls", namespace="formly")),
]
| eldarion/formly | formly/tests/urls.py | Python | bsd-3-clause | 249 | 0.004016 |
class GlibPackage (GnomeXzPackage):
def __init__ (self):
GnomePackage.__init__ (self,
'glib',
version_major = '2.30',
version_minor = '3')
self.darwin = Package.profile.name == 'darwin'
if Package.profile.name == 'darwin':
#link to specific revisions for glib 2.30.x
self.sources.extend ([
'h... | bl8/bockbuild | packages/glib.py | Python | mit | 1,520 | 0.046711 |
# -*- coding: utf-8 -*-
'''
Created on 23 mars 2014
@author: nestof
'''
class Parameter(object):
'''
classdocs
'''
tableName = 'parametrage'
colCodeName = 'code'
colTypeName = 'type'
colValueName = 'valeur'
colCommentName = 'commentaire'
def __init__(self):
... | nestof/domoCore | com/nestof/domocore/domain/Parameter.py | Python | gpl-3.0 | 482 | 0.006224 |
from django.shortcuts import redirect, render_to_response, render
from django.contrib.formtools.wizard.views import SessionWizardView
from django import forms, http
from models import Contact
from forms import ContactForm2
import collections
from datatableview.views import XEditableDatatableView, DatatableView
from dat... | liushu2000/django-crispy-formwizard | contact/views.py | Python | gpl-2.0 | 9,658 | 0.003935 |
#!/usr/bin/env python
"""
Copyright (c) 2015-2017 Alan Yorinks All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
Version 3 as published by the Free Software Foundation; either
or (at your option) any later version.... | MrYsLab/PyMata | examples/digital_analog_io/callback_buttonLed_toggle.py | Python | agpl-3.0 | 2,453 | 0.000408 |
#!/usr/bin/env python3
import datetime
import json
import os
import time
import signal
# attempt to ignore ctrl-z
signal.signal(signal.SIGTSTP, signal.SIG_IGN)
def blinking(string):
return '\33[5m' + string + '\33[0m'
BANNER = """ W e l c o m e t o
______ __
/ ____ \ ___ / /__________ _____
/ / ... | netsoc/admin_utils | freshers_signup.py | Python | gpl-3.0 | 4,811 | 0.002702 |
#!/usr/bin/env python
# encoding: utf-8
"""
${TM_NEW_FILE_BASENAME}.py
Created by ${TM_FULLNAME} on ${TM_DATE}.
Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
"""
from __future__ import absolute_import, division, print_function
import sys
import os
import unittest
class ${TM_NEW_FILE_BASENAM... | rcuza/init | devops/templates/python/python_class.py | Python | isc | 501 | 0 |
##############################################################################
#
# OSIS stands for Open Student Information System. It's an application
# designed to manage the core business of higher education institutions,
# such as universities, faculties, institutes and professional schools.
# The core ... | uclouvain/OSIS-Louvain | assessments/tests/business/test_score_encoding_progress.py | Python | agpl-3.0 | 14,789 | 0.004328 |
"""
Initialization script for restapi for the application.
"""
from flask import Blueprint
from app.common.logging import setup_logging
api = Blueprint('api', __name__)
# Setup logger
# api_log = setup_logging(__name__, 'logs/api.log', maxFilesize=1000000,
# backup_count=5)
from . import vie... | ibbad/dna-lceb-web | app/api_v1_0/__init__.py | Python | apache-2.0 | 331 | 0.003021 |
from gscripts import qtools
import sys, os
if not os.path.exists("fastqc/"):
os.mkdir("fastqc")
cmds = []
Sub = qtools.Submitter()
for fileName in sys.argv[1:]:
fastqc_command = "fastqc -o fastqc %s" %fileName
cmds.append(fastqc_command)
Sub.job(command_list=cmds, sh_file="runFastqc.sh", job_name=... | YeoLab/gscripts | gscripts/general/submit_fastqc.py | Python | mit | 403 | 0.009926 |
"""The tests for the Entity component helper."""
# pylint: disable=protected-access,too-many-public-methods
from collections import OrderedDict
import logging
import unittest
from unittest.mock import patch, Mock
import homeassistant.core as ha
import homeassistant.loader as loader
from homeassistant.helpers.entity im... | devdelay/home-assistant | tests/helpers/test_entity_component.py | Python | mit | 10,909 | 0 |
#!/usr/bin/env python
"""
Created on 28.10.2014
@author: evg-zhabotinsky
"""
from test_mir_common import *
mir = tirpan_get_mir('test_mir09.py')
n = find_mir_nodes(mir,
x_call = func_checker('x'),
y_call = func_checker('y'),
z_call = func_checker('z'),
... | bronikkk/tirpan | tests/accept_mir09.py | Python | gpl-3.0 | 1,313 | 0.007616 |
# -*- coding: utf-8 -*-
## Part of the pyprimes.py package.
##
## Copyright © 2014 Steven D'Aprano.
## See the file __init__.py for the licence terms for this software.
"""\
=====================================
Timing the speed of primes algorithms
=====================================
"""
from __future__ imp... | skilledindia/pyprimes | src/pyprimes/speed.py | Python | mit | 4,872 | 0.00349 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apach... | itskewpie/tempest | tempest/api/compute/volumes/test_volumes_negative.py | Python | apache-2.0 | 4,352 | 0 |
"""
Authorization module that allow users listed in
/etc/cobbler/users.conf to be permitted to access resources, with
the further restriction that cobbler objects can be edited to only
allow certain users/groups to access those specific objects.
Copyright 2008-2009, Red Hat, Inc and Others
Michael DeHaan <michael.deha... | shenson/cobbler | cobbler/modules/authz_ownership.py | Python | gpl-2.0 | 7,391 | 0.000541 |
# -*- coding: utf-8 -*-
import cherrypy
import errno
from ..describe import Description, autoDescribeRoute, describeRoute
from ..rest import Resource, filtermodel
from ...constants import AccessType, TokenScope
from girder.exceptions import AccessException, GirderException, RestException
from girder.models.assetstore ... | RafaelPalomar/girder | girder/api/v1/file.py | Python | apache-2.0 | 18,950 | 0.002058 |
# Copyright 2012 OpenStack, LLC
# 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 b... | BeenzSyed/tempest | tempest/services/database/json/database_client.py | Python | apache-2.0 | 1,757 | 0.007399 |
# -*- coding: utf-8 -*-
import unittest
from mock import Mock, patch
from flask import Flask
from werkzeug import exceptions, MultiDict
from werkzeug.wrappers import Request
from werkzeug.datastructures import FileStorage
from flask_restful.reqparse import Argument, RequestParser, Namespace
import six
import decimal
i... | ueg1990/flask-restful | tests/test_reqparse.py | Python | bsd-3-clause | 29,848 | 0.000905 |
from pulsar.utils.log import lazyproperty
from lux.models import fields
from lux.utils.data import as_tuple
from sqlalchemy.orm.exc import NoResultFound
def get_primary_keys(model):
"""Get primary key properties for a SQLAlchemy model.
:param model: SQLAlchemy model class
"""
mapper = model.__mappe... | quantmind/lux | lux/ext/odm/fields.py | Python | bsd-3-clause | 3,012 | 0 |
# ===============================================================================
# Copyright 2012 Jake Ross
#
# 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/licens... | USGSDenverPychron/pychron | pychron/processing/unmix.py | Python | apache-2.0 | 4,643 | 0.001077 |
import randomcolor
import random
def main():
hues = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink',
'monochrome', 'random']
luminosities = ['bright', 'light', 'dark', 'random']
formats = ['rgb', 'hex']
colors = []
rand_color = randomcolor.RandomColor(42)
rand = ra... | kevinwuhoo/randomcolor-py | tests/test_randomcolor_visual.py | Python | mit | 2,617 | 0.001911 |
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from metrics import memory
from metrics import Metric
class SystemMemoryMetric(Metric):
"""SystemMemoryMetric gathers system memory statistic.
This met... | TeamEOS/external_chromium_org | tools/perf/metrics/system_memory.py | Python | bsd-3-clause | 4,647 | 0.006025 |
# -*- coding: utf-8 -*-
import json
import yaml
import pytest
from unittest import TestCase
from lain_sdk.yaml.parser import (
LainConf, ProcType, Proc,
just_simple_scale,
render_resource_instance_meta, DEFAULT_SYSTEM_VOLUMES,
DOMAIN,
MIN_SETUP_TIME, MAX_SETUP_TIME, MIN_KILL_TIMEOUT, MAX_KILL_TIMEO... | supermeng/lain-sdk | tests/test_lain_conf.py | Python | mit | 81,042 | 0.000913 |
# -*- coding: utf-8 -*-
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | google/mirandum | alerts/ytsubs/migrations/0004_migrate_updater.py | Python | apache-2.0 | 1,359 | 0.004415 |
# coding=utf-8
import os
import time
import urllib
import urllib2
import random
import string
import json
from flask import url_for
from flask import redirect
from flask import request
from flask import session
from flask import flash
from flask import current_app
from flask.ext.login import login_user
from . import ... | thundernet8/WRGameVideos-Server | app/auth/views.py | Python | gpl-2.0 | 2,080 | 0.002404 |
"""
Alternative convolution implementations for Theano
"""
import numpy as np
import theano
import theano.tensor as T
## 1D convolutions
def conv1d_sc(input, filters, image_shape=None, filter_shape=None, border_mode='valid', subsample=(1,)):
"""
using conv2d with a single input channel
"""
if borde... | diogo149/Lasagne | lasagne/theano_extensions/conv.py | Python | mit | 8,695 | 0.006325 |
# 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 use ... | eljefe6a/kafka | tests/kafkatest/tests/upgrade_test.py | Python | apache-2.0 | 3,776 | 0.002913 |
import datetime
class Item(object):
def __init__(self, item):
self.title = item['title'].encode("utf-8")
self.url = self.get_starred_url(item)
self.content = self.get_content(item)
self.datestamp = item['published']
self.date = datetime.datetime.fromtimestamp(self.datestamp).strftime('%m-%Y')
def gens... | kamiben/starred | item.py | Python | mit | 1,978 | 0.039939 |
# collect all the articles' title in a list from different sections
from search_articles import get_articles_name
def get_articles(sections):
i = 1
title_list = []
for section in sections:
for title in get_articles_name(str(section)):
title_list += [title]
return title_list | leaot/Huffpost-Articles-in-Twitter-Trends | Python/article_engin.py | Python | mit | 314 | 0.003185 |
# 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.
import ctypes
import ctypes.util
import logging
import os
import platform
import sys
import time
import threading
GET_TICK_COUNT_LAST_NOW = 0
# If GET_TICK... | cricketclubucd/davisdragons | platform-tools/systrace/catapult/common/py_trace_event/py_trace_event/trace_time.py | Python | mit | 7,242 | 0.009804 |
from constraint_handler import *
from rated_statistic_storage import *
import rospy
from arni_msgs.msg import RatedStatistics
from arni_core.host_lookup import *
from std_srvs.srv import Empty
import helper
import time
class CountermeasureNode(object):
"""A ROS node.
Evaluates incoming rated statistics with ... | andreasBihlmaier/arni | arni_countermeasure/src/arni_countermeasure/countermeasure_node.py | Python | bsd-2-clause | 3,842 | 0.00026 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014, 2015, 2016 Adam.Dybbroe
# Author(s):
# Adam.Dybbroe <adam.dybbroe@smhi.se>
# Janne Kotro fmi.fi
# Trygve Aspenes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as ... | TAlonglong/trollduction-test | aapp_runner/aapp_dr_runner.py | Python | gpl-3.0 | 72,713 | 0.003782 |
#!/usr/bin/env python
# test --create
command += oiiotool ("--create 320x240 3 -d uint8 -o black.tif")
command += oiiotool ("--stats black.tif")
# test --pattern constant
command += oiiotool ("--pattern constant:color=.1,.2,.3,1 320x240 4 -o constant.tif")
command += oiiotool ("--stats constant.tif")
# test --patte... | OpenImageIO/oiio | testsuite/oiiotool-pattern/run.py | Python | bsd-3-clause | 3,464 | 0.01097 |
from django.db import models
class Music(models.Model):
url = models.CharField('URL', max_length=255)
title = models.CharField('título', max_length=200, blank=True)
artist = models.CharField('artista', max_length=200, blank=True)
genre = models.CharField('gênero', max_length=100, blank=True)
file ... | Lrcezimbra/ganso-music | gansomusic/core/models.py | Python | gpl-3.0 | 355 | 0 |
###########################################################
#
# Copyright (c) 2005, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permi... | sadanandb/pmt | src/pyasm/web/__init__.py | Python | epl-1.0 | 931 | 0.003222 |
#from __future__ import print_function
import ast
import os
import sys
import codecs
import subprocess
from fnmatch import fnmatchcase
from distutils.util import convert_path
from setuptools import setup, find_packages
def find_version(*parts):
try:
version_py = os.path.join(os.path.dirname(__file__), 'dj... | dalou/django-extended | setup.py | Python | bsd-3-clause | 2,148 | 0.00419 |
#
# Copyright (c) 2008-2015 Citrix 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | benfinke/ns_python | nssrc/com/citrix/netscaler/nitro/resource/config/authentication/authenticationpolicylabel.py | Python | apache-2.0 | 9,779 | 0.038757 |
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe import _
from erpnext.education.utils import validate_duplicate_student
from ... | gsnbng/erpnext | erpnext/education/doctype/student_group/student_group.py | Python | agpl-3.0 | 5,632 | 0.022905 |
# vim: set fileencoding=utf-8 :
# Copyright (C) 2008 Joao Paulo de Souza Medeiros.
#
# Author(s): João Paulo de Souza Medeiros <ignotus21@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Founda... | labepi/destate | gui/AutomataManage.py | Python | gpl-2.0 | 16,796 | 0.002739 |
#
# Copyright (c) SAS Institute 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 w... | sassoftware/rbuild | plugins/createprojectbranch.py | Python | apache-2.0 | 8,529 | 0.00129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.