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 |
|---|---|---|---|---|---|
#!/usr/bin/python
# -*- coding: utf-8 -*-
###############################################################################
#
# A tool to search for geonames metadata either:
# - the path of a geocoded picture
# - by giving a latitude and longitude values (decimal degrees format)
#
# (c) francois.schnell francois.schne... | dhamaniasad/gpicsync | geonames.py | Python | gpl-2.0 | 6,231 |
from django.test import TestCase
from io import BytesIO
from rest_framework.parsers import JSONParser
def parseJSON(response):
stream = BytesIO(response.content)
json = JSONParser().parse(stream)
return json
class Test(TestCase):
def test_no_permission(self):
response = self.client.get('/')
... | derpingallday/django-rest-swagger | tests/cigar_example/cigar_example/test_example.py | Python | bsd-2-clause | 622 |
from __future__ import absolute_import, unicode_literals
import random
from threading import Lock
from fake_useragent import settings
from fake_useragent.utils import load, load_cached, update
class UserAgent(object):
lock = Lock() # mutable cross-instance threading.Lock
def __init__(self, cache=True):
... | Maximilian-Reuter/SickRage-1 | lib/fake_useragent/fake.py | Python | gpl-3.0 | 1,434 |
#!/usr/bin/env python
'''
EC2 external inventory script
=================================
Generates inventory that Ansible can understand by making API request to
AWS EC2 using the Boto library.
NOTE: This script assumes Ansible is being executed where the environment
variables needed for Boto have already been set:... | darkk/ansible | plugins/inventory/ec2.py | Python | gpl-3.0 | 20,903 |
# BER encoder
from pyasn1.type import base, tag, univ, char, useful
from pyasn1.codec.ber import eoo
from pyasn1.compat.octets import int2oct, ints2octs, null, str2octs
from pyasn1 import error
class Error(Exception): pass
class AbstractItemEncoder:
supportIndefLenMode = 1
def encodeTag(self, t, isConstructed... | AdrianGaudebert/socorro-crashstats | vendor-local/lib/python/pyasn1/codec/ber/encoder.py | Python | mpl-2.0 | 12,392 |
# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | yuewko/neutron | neutron/tests/unit/tests/test_base.py | Python | apache-2.0 | 1,600 |
from tests import BaseTestCase
from redash.models import ApiKey
class TestApiKeyGetByObject(BaseTestCase):
def test_returns_none_if_not_exists(self):
dashboard = self.factory.create_dashboard()
self.assertIsNone(ApiKey.get_by_object(dashboard))
def test_returns_only_active_key(self):
... | jmvasquez/redashtest | tests/models/test_api_keys.py | Python | bsd-2-clause | 634 |
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | ntt-sic/neutron | neutron/openstack/common/notifier/api.py | Python | apache-2.0 | 5,734 |
# 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... | eadgarchen/tensorflow | tensorflow/python/estimator/util_test.py | Python | apache-2.0 | 3,897 |
#!/usr/bin/python
# (c) 2017, NetApp, Inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
... | hryamzik/ansible | lib/ansible/modules/storage/netapp/na_cdot_volume.py | Python | gpl-3.0 | 15,029 |
# Author: Ovidiu Predescu
# Date: July 2011
#
# 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 ... | Batterfii/tornado | tornado/platform/twisted.py | Python | apache-2.0 | 21,586 |
# test builtin dir
# dir of locals
print('__name__' in dir())
# dir of module
import sys
print('platform' in dir(sys))
class Foo:
def __init__(self):
self.x = 1
foo = Foo()
print('__init__' in dir(foo))
print('x' in dir(foo))
| EcmaXp/micropython | tests/basics/builtin_dir.py | Python | mit | 242 |
# coding: utf-8
import warnings
from ruamel.yaml.util import configobj_walker as new_configobj_walker
def configobj_walker(cfg):
warnings.warn("configobj_walker has move to ruamel.yaml.util, please update your code")
return new_configobj_walker(cfg)
| naparuba/opsbro | opsbro/misc/internalyaml/ruamel/yaml/configobjwalker.py | Python | mit | 261 |
#!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible is distribut... | hryamzik/ansible | lib/ansible/modules/network/nxos/nxos_interface_ospf.py | Python | gpl-3.0 | 17,076 |
#!/usr/bin/env python
# This example demonstrates the use of 2D text the old way by using a
# vtkTextMapper and a vtkScaledTextActor.
import vtk
# Create a sphere source, mapper, and actor
sphere = vtk.vtkSphereSource()
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(sphere.GetOutputPort())
s... | HopeFOAM/HopeFOAM | ThirdParty-0.1/ParaView-5.0.1/VTK/Examples/Annotation/Python/TestTextOldWay.py | Python | gpl-3.0 | 1,475 |
#!/usr/bin/python
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
... | valentin-krasontovitsch/ansible | lib/ansible/modules/cloud/amazon/elb_classic_lb.py | Python | gpl-3.0 | 53,523 |
#: Okay
# 情
#: W291:1:6
print
#: W293:2:1
class Foo(object):
bang = 12
#: W291:2:35
'''multiline
string with trailing whitespace'''
#: W292:1:36 noeol
# This line doesn't have a linefeed
#: W292:1:5 E225:1:2 noeol
1+ 1
#: W292:1:27 E261:1:12 noeol
import this # no line feed
#: W292:3:22 noeol
class Test(object):
... | urisimchoni/samba | third_party/pep8/testsuite/W29.py | Python | gpl-3.0 | 367 |
from MeshInfo import *
''' Provides Information about ExodusII meshes '''
class ExodusIIMeshInfo(MeshInfo):
def __init__(self, mesh_item_data, file_name):
MeshInfo.__init__(self, mesh_item_data)
self.file_name = file_name
import vtk
reader = vtk.vtkExodusIIReader()
reader.SetFileName(self.file_na... | gleicher27/Tardigrade | moose/gui/mesh_info/ExodusIIMeshInfo.py | Python | lgpl-2.1 | 1,654 |
#------------------------------------------------------------------------------
# pycparser: c_parser.py
#
# CParser class: Parser and AST builder for the C language
#
# Copyright (C) 2008-2015, Eli Bendersky
# License: BSD
#------------------------------------------------------------------------------
import re
from ... | pcu4dros/pandora-core | workspace/lib/python3.5/site-packages/pycparser/c_parser.py | Python | mit | 63,805 |
"""
25. Reverse lookups
This demonstrates the reverse lookup features of the database API.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class User(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
... | diegoguimaraes/django | tests/reverse_lookup/models.py | Python | bsd-3-clause | 823 |
import pytest
@pytest.fixture
def create_files(tmpdir_factory):
def inner(filenames):
filelist = []
tmpdir = tmpdir_factory.mktemp("tmp")
for filename in filenames:
fh = tmpdir.join(filename)
fh.write(filename)
filelist.append(fh)
return filelis... | scheib/chromium | third_party/blink/web_tests/external/wpt/webdriver/tests/element_send_keys/conftest.py | Python | bsd-3-clause | 376 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0029_realm_subdomain'),
]
operations = [
migrations.AddField(
model_name='realm',
name='or... | sonali0901/zulip | zerver/migrations/0030_realm_org_type.py | Python | apache-2.0 | 409 |
#!/usr/bin/env python
# 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.
"""Test resources processing, i.e. <if> and <include> tag handling."""
import unittest
from processor import FileCache, Processor, Lin... | Teamxrtc/webrtc-streaming-node | third_party/webrtc/src/chromium/src/third_party/closure_compiler/processor_test.py | Python | mit | 3,825 |
import sys
class DVCS(object):
def __init__(self, path, repo):
self.path = path
self.url = repo['url']
self.type = repo['type']
self.draft_branch = repo['draft_branch']
self.prod_branch = repo['production_branch']
self.switch(self.draft_branch) ... | npettiaux/hyde | repos/dvcs.py | Python | mit | 952 |
"""
Tests of student.roles
"""
import ddt
from django.test import TestCase
from courseware.tests.factories import UserFactory, StaffFactory, InstructorFactory
from student.tests.factories import AnonymousUserFactory
from student.roles import (
GlobalStaff, CourseRole, CourseStaffRole, CourseInstructorRole,
Or... | olexiim/edx-platform | common/djangoapps/student/tests/test_roles.py | Python | agpl-3.0 | 7,708 |
# Copyright (c) 2008 The Regents of The University of Michigan
# 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 ... | austinharris/gem5-riscv | src/dev/x86/I8042.py | Python | bsd-3-clause | 2,210 |
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
# All Right Reserved
#
# Author : Nicolas Bessi (Camptocamp)
# Contributor(s) : Florent Xicluna (Wingo SA)
#
# WARNING: This program as such is intended... | ncliam/serverpos | openerp/addons/report_webkit/webkit_report.py | Python | agpl-3.0 | 16,744 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Ansible module to manage Icinga2 feature state
(c) 2016, Loic Blot <loic.blot@unix-experience.fr>
Sponsored by Infopro Digital. http://www.infopro-digital.com/
Sponsored by E.T.A.I. http://www.etai.fr/
This file is part of Ansible
Ansible is free software: you can redi... | andreaso/ansible | lib/ansible/modules/monitoring/icinga2_feature.py | Python | gpl-3.0 | 4,541 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=========================================================
Vector Quantization Example
=========================================================
Face, a 1024 x 768 size image of a raccoon face,
is used here to illustrate how `k`-means is
used for vector quantization.
"""
... | chenyyx/scikit-learn-doc-zh | examples/zh/cluster/plot_face_compress.py | Python | gpl-3.0 | 2,198 |
import gdb
import glib
import gdb.backtrace
import gdb.command.backtrace
# This is not quite right, as local vars may override symname
def read_global_var (symname):
return gdb.selected_frame().read_var(symname)
def g_type_to_name (gtype):
def lookup_fundamental_type (typenode):
if typenode == 0:
... | JoGall/ubitrail | windowsBuild/share/glib-2.0/gdb/gobject.py | Python | gpl-3.0 | 9,374 |
# If you run this file, it will make up a random secret and then crack it
# using timing information from a string comparison function. Maybe--if it
# gets lucky. It takes a long, long time to work.
# So, the thing I need help with is statistics. The way this thing works is
# extremely stupid. Suppose you want to know... | heathseals/CouchPotatoServer | libs/pyutil/scripts/time_comparisons.py | Python | gpl-3.0 | 8,758 |
"""Check for errs in the AST.
The Python parser does not catch all syntax errors. Others, like
assignments with invalid targets, are caught in the code generation
phase.
The compiler package catches some errors in the transformer module.
But it seems clearer to write checkers that use the AST to detect
errors.
"""
... | zephyrplugins/zephyr | zephyr.plugin.jython/jython2.5.2rc3/Lib/compiler/syntax.py | Python | epl-1.0 | 1,444 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("migrations", "0001_initial")]
operations = [
migrations.CreateModel(
"Something",
[
("id", model... | gitaarik/django | tests/migrations/test_migrations_conflict/0002_conflicting_second.py | Python | bsd-3-clause | 384 |
# -*- coding: utf-8 -*- vim:fileencoding=utf-8:
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
# Copyright © 2010-2012 Greek Research and Technology Network (GRNET S.A.)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that th... | apoikos/servermon | hwdoc/vendor/dummy.py | Python | isc | 2,909 |
# constraints should be multiplicative so we can do them in any order
# ok, maybe not multiplicative. not sure yet.
# want to avoid plateaus in the space.
import copy
import numpy as np
from scipy.special import binom
import scipy
import librosa_analysis
import novelty
BEAT_DUR_KEY = "med_beat_duration"
class Co... | ucbvislab/radiotool | radiotool/algorithms/constraints.py | Python | isc | 27,809 |
# secretkey.py: secret-key cryptographic functions
"""
Secret-key functions from chapter 1 of "A Working Introduction to
Cryptography with Python".
"""
import Crypto.Cipher.AES as AES
import Crypto.Hash.HMAC as HMAC
import Crypto.Hash.SHA384 as SHA384
import Crypto.Random.OSRNG.posix as RNG
import pbkdf2
import streql... | kisom/crypto_intro | src/secretkey.py | Python | isc | 2,939 |
from descriptors.utils.Prepareable import Prepareable
| noutenki/descriptors | descriptors/utils/__init__.py | Python | mit | 54 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Windows Start Guide documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 12 02:52:30 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present ... | hitsumabushi/windows_start_guide | source/conf.py | Python | mit | 9,370 |
from django.contrib import admin
from pypi.models import Package
class PackageAdmin(admin.ModelAdmin):
search_fields = ('name',)
readonly_fields = Package._meta.get_all_field_names()
has_add_permission = lambda s, r: False
has_delete_permission = lambda s, r, o = None: False
list_display = ('name... | kitsunde/django-pypi | pypi/admin.py | Python | mit | 394 |
#This script will build the main subpackages
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration, get_info
config = Configuration('ksl', parent_package, top_path)
tt_dir = '../tt-fort/'
exp_dir = '../tt-fort/expm'
src = ['ttals.f90','tt_ksl.f90']... | gasongjian/ttpy | tt/ksl/setup.py | Python | mit | 1,357 |
from django.conf.urls import patterns, include, url
from django.contrib.sitemaps import Sitemap
from django.views.generic import TemplateView
from django.contrib import admin
from {{ project_name }}.views import HomePageView, ContactPageView, RobotPageView, HumanPageView
from {{ project_name }}.sitemap import BlogSitem... | vandorjw/django-template-project | project/project_name/urls.py | Python | mit | 1,221 |
# -*- coding: utf-8 -*-
import scrapy
import logging
from datetime import datetime
try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin
from .delta_helper import DeltaHelper
class BaseSpider(scrapy.Spider):
# need overwrite in subclass
logger = logging.getLogger(__nam... | loggerhead/dianping_crawler | dianping_crawler/spiders/base_spider.py | Python | mit | 1,618 |
import os
from popper import __version__
from popper.cli import log
from popper.exporter import WorkflowExporter
from .test_common import PopperTest
class TestExporter(PopperTest):
@classmethod
def setUpClass(self):
log.setLevel("CRITICAL")
def test_get_matrix_variables(self):
given = [... | systemslab/popper | src/test/test_exporter.py | Python | mit | 2,927 |
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from Stream import *
from WindowOperators import window_split
from PrintFunctions import print_streams_recent
def ... | zatricion/Streams | ExamplesWindowOperations/ExamplesWindowSplitNoState.py | Python | mit | 1,672 |
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
import copy
import re
from urllib.parse import urlparse
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.service import OpenGraphThumbMix... | olof/svtplay-dl | lib/svtplay_dl/service/flowonline.py | Python | mit | 1,384 |
# Test for one implementation of the interface
from lexicon.providers.nsone import Provider
from integration_tests import IntegrationTests
from unittest import TestCase
import pytest
# Hook into testing framework by inheriting unittest.TestCase and reuse
# the tests which *each and every* implementation of the interfa... | tnwhitwell/lexicon | tests/providers/test_nsone.py | Python | mit | 972 |
# Generated by Django 3.1.3 on 2020-11-19 15:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('flickr', '0023_auto_20180104_1457'),
]
operations = [
migrations.AddField(
model_name='photo',
name='x_large_3k_heig... | philgyford/django-ditto | ditto/flickr/migrations/0024_auto_20201119_1539.py | Python | mit | 1,708 |
import pytest
from aiohttp import web
from aiohttp_utils.runner import Runner
class TestRunner:
def test_bind(self):
app = web.Application()
runner = Runner(app, host='1.2.3.4', port=5678,
app_uri='http://1.2.3.4:5678')
assert runner.bind == '1.2.3.4:5678'
def... | sloria/aiohttp_utils | tests/test_runner.py | Python | mit | 1,003 |
from __future__ import unicode_literals
from __future__ import print_function
from ..compat import implements_to_string, text_type
class MoyaRuntimeError(Exception):
def __init__(self):
pass
@implements_to_string
class MissingTemplateError(Exception):
hide_py_traceback = True
error_type = "Miss... | moyaproject/moya | moya/template/errors.py | Python | mit | 3,482 |
__all__ = ['jazPrint', 'jazShow']
class jazPrint:
def __init__(self):
self.command = "print";
def call(self, interpreter, arg):
return interpreter.GetScope().GetStackTop()
class jazShow:
def __init__(self):
self.command = "show";
def call(self, interpreter, arg):
re... | joewashear007/jazzy | jazzy/functions/OutputFunc.py | Python | mit | 462 |
from os import path
from stayput.importer import import_file
from stayput.tests import TestCase
FIXTURE = path.abspath(path.join(path.dirname(__file__), 'fixtures', 'import_test.py'))
class TestImporter(TestCase):
# see fixtures/import_test.py.
def test_import(self):
result = import_file(FIXTURE)
... | veeti/stayput | stayput/tests/test_importer.py | Python | mit | 478 |
from datetime import datetime
import os
import sys
import time
import boto.ec2
from fabric.api import cd, env, prefix, put, run, settings, sudo, task
env.user = 'vagrant'
env.hosts = ['127.0.0.1:2222']
key_fname = os.path.join('~', '.vagrant.d', 'insecure_private_key')
env.key_filename = os.path.expanduser(key_fnam... | iw/mirage-jekyll | fabfile.py | Python | mit | 6,415 |
# FILE CONTENT GENERATED FROM SETUP.PY
short_version = '1.0.0'
version = '1.0.0'
full_version = '1.0.0'
release = True
if not release:
version = full_version
| RonsenbergVI/trendpy | trendpy/version.py | Python | mit | 163 |
from collections import defaultdict
class CategoricalVariableEncoder(object):
def convert_categorical_variables(self, data_matrix, category_indices, category_value_mapping=None):
if len(category_indices) == 0:
return data_matrix
if category_value_mapping == None:
category_v... | wangjohn/wallace | wallace/categorical_variable_encoder.py | Python | mit | 1,836 |
#
# Copyright (C) 2018 - 2021 Satoru SATOH <satoru.satoh@gmail.com>
# SPDX-License-Identifier: MIT
#
# pylint: disable=missing-docstring, invalid-name
import anyconfig.models.processor
class A(anyconfig.models.processor.Processor):
_cid = 'A'
_type = 'json'
_extensions = ['json', 'jsn', 'js']
class A2(A... | ssato/python-anyconfig | tests/processors/common.py | Python | mit | 800 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Reading, writing, and describing memory.
"""
import gdb
import pwndbg.compat
import pwndbg.typeinfo
PAGE_SIZE = 0x1000
PAGE_MASK = ~(PAGE_SIZE-1)
MMAP_MIN_ADDR = 0x8000
def read(addr, count, partial=False):
result = ''
try:
result = gdb.selected_infer... | bj7/pwndbg | pwndbg/memory.py | Python | mit | 5,918 |
__author__ = 'sibirrer'
#this file is ment to be a shell script to be run with Monch cluster
# set up the scene
from cosmoHammer.util.MpiUtil import MpiPool
import time
import sys
import pickle
import dill
start_time = time.time()
#path2load = '/mnt/lnec/sibirrer/input.txt'
path2load = str(sys.argv[1])
f = open(pa... | DES-SL/EasyLens | easylens/Scripts/des_script.py | Python | mit | 1,168 |
import unittest
import pytest
from engineio import packet
class TestPacket(unittest.TestCase):
def test_encode_default_packet(self):
pkt = packet.Packet()
assert pkt.packet_type == packet.NOOP
assert pkt.data is None
assert not pkt.binary
assert pkt.encode() == '6'
d... | miguelgrinberg/python-engineio | tests/common/test_packet.py | Python | mit | 4,720 |
#!/usr/bin/python
#
# Author: Paul D. Eden <paul@benchline.org>
# Created: 2014-03-19
"""
Calculates the difference between two dates in days, months and years
and prints them.
"""
import datetime
import ago
import six
import benchline.args
def _valid_date_str(date_str):
"""
>>> _valid_date_str("2014-02-02"... | pauldeden/benchline | benchline/date_diff.py | Python | mit | 1,907 |
d = {'key1': 1, 'key2': 2, 'key3': 3}
for k in d:
print(k)
# key1
# key2
# key3
for k in d.keys():
print(k)
# key1
# key2
# key3
keys = d.keys()
print(keys)
print(type(keys))
# dict_keys(['key1', 'key2', 'key3'])
# <class 'dict_keys'>
k_list = list(d.keys())
print(k_list)
print(type(k_list))
# ['key1', 'key... | nkmk/python-snippets | notebook/dict_keys_values_items.py | Python | mit | 1,226 |
"""Reading Excel
This program uses :py:mod:`openpyxl` to read Excel documents.
"""
def main():
# Opening Excel Documents with OpenPyXL
import openpyxl
print(openpyxl.__version__) # Using version 2.5.5
wb = openpyxl.load_workbook("example.xlsx")
print(type(wb))
# Getting Sheets from the Wo... | JoseALermaIII/python-tutorials | pythontutorials/books/AutomateTheBoringStuff/Ch12/P1_readingExcel.py | Python | mit | 2,109 |
def triangle_sum(tri, r, c, h, memo):
if (r, c, h) in memo:
return memo[(r, c, h)]
ans = tri[r][c]
if h > 0:
ans += triangle_sum(tri, r + 1, c, h - 1, memo)
ans += triangle_sum(tri, r + 1, c + 1, h - 1, memo)
if h > 1:
ans -= triangle_sum(tri, r + 2, c + 1, h - 2, memo)... | simonolander/euler | euler-150-searching-a-triangular-array-for-a-sub-triangle-having-minimum-sum.py | Python | mit | 1,906 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
class ValidationError(ValueError):
pass
| HeathKang/flasky | app/exceptions.py | Python | mit | 90 |
import pytracer.color
import pytracer.materials
import pytracer.camera
import pytracer.scene
import pytracer.objects
import pytracer.vector
import pytracer.main
import pytracer.lights
import pytracer.ray
| cocreature/pytracer | __init__.py | Python | mit | 204 |
"""
html-pdf-webservice
Copyright 2014 Nathan Jones
See LICENSE for more details
"""
from unittest.case import TestCase
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
from app import application
class AppTest(TestCase):
def setUp(self):
self.client = Client(appl... | admetricks/printer-webservice | tests.py | Python | mit | 1,374 |
#!/usr/bin/env python
#
# Electrum - lightweight NavCoin client
# Copyright (C) 2011 thomasv@gitorious
#
# 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 witho... | sherlockcoin/Electrum-NavCoin | lib/commands.py | Python | mit | 32,053 |
import re
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapybol.items import ScrapybolItem
from bs4 import BeautifulSoup
from urllib2 import urlopen
class BolSpider(BaseSpider):
name = "bol"
allowed_domains = ["bol.com"]
base_url = 'http://www.bol.com/nl/l/n... | mblaauw/scrapybol | scrapybol/spiders/bol_spider.py | Python | mit | 2,471 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-05-02 06:40
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projects', '0025_remove_project_content_types'),
]
operations = [
migration... | tddv/readthedocs.org | readthedocs/projects/migrations/0026_project_content_types.py | Python | mit | 564 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cdadmap', '0036_auto_20151105_1350'),
]
operations = [
migrations.AddField(
model_name='locationpanel',
... | NiJeLorg/CDADMap | cdad/cdadmap/migrations/0037_auto_20151106_1149.py | Python | mit | 1,088 |
#! /usr/bin/env python3
import sys
from itertools import product
from mule_local.JobMule import *
from mule.exec_program import *
from mule.InfoError import *
jg = JobGeneration()
"""
Compile parameters
"""
params_compile_sweet_mpi = ['enable', 'disable']
params_compile_threading = ['omp', 'off']
params_compile_th... | schreiberx/sweet | tests/20_platforms_job_generation/benchmark_create_job_scripts.py | Python | mit | 3,673 |
"""A pseudo-file mapped into memory
Provides better performance for frequent reads/writes,
and makes reading/writing easier via regions (windows)
of memory. Allows memory to be accessed via array reads/
writes as well.
"""
import mmap
import logging
log = logging.getLogger(__name__)
class ReadOnlyError(Exception):... | Qix-/starfuse | starfuse/fs/mapped_file.py | Python | mit | 7,231 |
# -*- coding: utf-8 -*-
"""Utilities for working with ECS task definitions."""
import json
import os
from .. import client as boto3client
def create(profile, contents=None, filepath=None):
"""Upload a task definition to ECS.
Args:
profile
A profile to connect to AWS with.
cont... | jtpaasch/armyguys | armyguys/aws/ecs/taskdefinition.py | Python | mit | 3,013 |
#!/usr/bin/env python
"""
Solution to Day X - Puzzle X of the Advent Of Code 2015 series of challenges.
--- Day X: Day X Title ---
Description of Puzzle
-----------------------------------------
Author: Luke "rookuu" Roberts
"""
from collections import defaultdict
from itertools import permutations
inputFile = op... | rookuu/AdventOfCode-2015 | Day 9/Puzzle 1 and 2.py | Python | mit | 998 |
"""followers
Revision ID: 2356a38169ea
Revises: 288cd3dc5a8
Create Date: 2013-12-31 16:10:34.500006
"""
# revision identifiers, used by Alembic.
revision = '2356a38169ea'
down_revision = '288cd3dc5a8'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by... | mrcatacroquer/Bridge | migrations/versions/2356a38169ea_followers.py | Python | mit | 941 |
import _plotly_utils.basevalidators
class OutlinecolorValidator(_plotly_utils.basevalidators.ColorValidator):
def __init__(
self, plotly_name="outlinecolor", parent_name="contourcarpet.colorbar", **kwargs
):
super(OutlinecolorValidator, self).__init__(
plotly_name=plotly_name,
... | plotly/python-api | packages/python/plotly/plotly/validators/contourcarpet/colorbar/_outlinecolor.py | Python | mit | 490 |
# Mp3 metadata testing...
from ID3 import *
# TODO add further directory search methods
import os
class mp3data:
def trial(self):
try:
filename = 'testfolder/furelise.mp3'
id3info = ID3(filename)
for i in id3info.items():
continue # print i
... | aperture321/hipbit | src/mp3metadata.py | Python | mit | 1,505 |
from jsonrpc import ServiceProxy
import sys
import string
# ===== BEGIN USER SETTINGS =====
# if you do not set these you will be prompted for a password for every command
rpcuser = ""
rpcpass = ""
# ====== END USER SETTINGS ======
if rpcpass == "":
access = ServiceProxy("http://127.0.0.1:9332")
else:
access = Ser... | juanbond/doctorcoin | contrib/bitrpc/bitrpc.py | Python | mit | 7,842 |
"""Agent tests."""
# pylint: disable=missing-docstring,too-few-public-methods
import sys
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python.failure import Failure
from twisted.trial.unittest import TestCase
from twisted.web.client import Headers, Response, ResponseDone, readBody
from... | kxz/stenographer | stenographer/test/test_agent.py | Python | mit | 4,201 |
# $Id: HC.py,v 1.2 2005-07-14 01:36:41 gosselin_a Exp $
# $Log: not supported by cvs2svn $
# Revision 1.1 2004/08/02 15:36:04 gosselin
# Initial revision
#
from . import hdfext as _C
class HC(object):
"""The HC class holds constants defining opening modes and data types.
File opening modes (flags ORed together... | fhs/pyhdf | pyhdf/HC.py | Python | mit | 1,928 |
if __name__ == '__main__':
s = input()
is_list = list(zip(*[[c.isalnum(), c.isalpha(), c.isdigit(), c.islower(), c.isupper()] for c in s]))
print_list = [True if True in is_result else False for is_result in is_list]
for result in print_list:
print(result)
| nifannn/HackerRank | Practice/Python/Strings/string_validators.py | Python | mit | 281 |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes ... | Azure/azure-sdk-for-python | sdk/graphrbac/azure-graphrbac/azure/graphrbac/models/domain_py3.py | Python | mit | 2,154 |
import os
import boto
# Before running this script, set envars AWS_ACCESS_KEY_ID
# and AWS_SECRET_ACCESS_KEY, Boto uses them automatically
# ember build --environment="production"
print boto.s3.regions()
conn = boto.connect_s3()
bucket = conn.get_bucket('nodember-rain')
for root, folder, files in os.walk('frontend/d... | holandes22/nodember-rain | deploy.py | Python | mit | 674 |
# The MIT License (MIT)
#
# Copyright shifvb 2015
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... | shifvb/DarkChina | http_proxy/tools/async_IO.py | Python | mit | 1,931 |
"""
Operations:
P - login
G - list - list the dir's content
G - read - reads a file
G - info - infos about a file
P - write - writes a file
P - mkdir - makes a dir
P - copy - to=...
P - move - to=...
P - delete - DELETE
P - logout
"""
import canister
import bottle
import os.path
import json
imp... | dagnelies/restfs | old/restfs.py | Python | mit | 4,068 |
import sys
class Message:
def __init__(self, row, message):
self.row = row
self.message = message
def toString(self):
if (self.row):
return str(self.row) + ": " + self.message
else:
return self.message
class ErrorLog:
def __init__(self):
self.log = []
self.emit = True # print to console on add
... | seece/cbpp | error.py | Python | mit | 730 |
import numpy as np
from feature_loader import FeatureExtract
import operator
from collections import OrderedDict
class Importance:
def __init__(self, algo, fObj):
if algo.lower() not in ['xgboost', 'random_forest', 'k_best', '*']:
raise NotImplementedError("Algorithm support not implemented")... | MayukhSobo/EnronFraud | feature_engineering/feature_importance.py | Python | mit | 7,787 |
import _plotly_utils.basevalidators
class ValuessrcValidator(_plotly_utils.basevalidators.SrcValidator):
def __init__(
self, plotly_name="valuessrc", parent_name="splom.dimension", **kwargs
):
super(ValuessrcValidator, self).__init__(
plotly_name=plotly_name,
parent_nam... | plotly/python-api | packages/python/plotly/plotly/validators/splom/dimension/_valuessrc.py | Python | mit | 466 |
import asyncio
from unittest import mock
from aiorpcx import RPCError
from server.env import Env
from server.controller import Controller
loop = asyncio.get_event_loop()
def set_env():
env = mock.create_autospec(Env)
env.coin = mock.Mock()
env.loop_policy = None
env.max_sessions = 0
env.max_subs... | erasmospunk/electrumx | tests/server/test_api.py | Python | mit | 2,877 |
"""Tests for update records."""
import unittest
from dbdiff.fixture import Fixture
from .base import TestImportBase, FixtureDir
class TestUpdate(TestImportBase):
"""Tests update procedure."""
def test_update_fields(self):
"""Test all fields are updated."""
fixture_dir = FixtureDir('update')
... | yourlabs/django-cities-light | src/cities_light/tests/test_update.py | Python | mit | 5,691 |
# coding=utf-8
r"""
This code was generated by
\ / _ _ _| _ _
| (_)\/(_)(_|\/| |(/_ v1.0.0
/ /
"""
from tests import IntegrationTestCase
from tests.holodeck import Request
from twilio.base.exceptions import TwilioException
from twilio.http.response import Response
class FaxMediaTestCase(Integrat... | tysonholub/twilio-python | tests/integration/fax/v1/fax/test_fax_media.py | Python | mit | 4,434 |
from django.conf.urls import patterns, url
urlpatterns = patterns('empresas.views',
url(r'^empresas/$', 'empresas_index', name="lista_empresas"),
url(r'^empresa/(?P<id>\w+)/$', 'empresas_pagina', name="empresas_pagina"),
url(r'^mapa_completo_empresa/$', 'mapa_completo_empresa', name="mapa-compl... | CARocha/simasinnovacion | empresas/urls.py | Python | mit | 785 |
# for Python3 we need a fully qualified name import
from mappyscript._mappyscript import version, version_number, load, loads, dumps, create_request, load_map_from_params, Layer, convert_sld | geographika/mappyscript | mappyscript/__init__.py | Python | mit | 190 |
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
class Clipboard(object):
"""A wrapper around GTK3's clipboard interface. Text only."""
def __init__(self):
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self.text = None
def __repr__(self):
... | Notgnoshi/clippy | clippy/clipboard.py | Python | mit | 1,004 |
from colorsys import rgb_to_hsv
import time
def id_generator():
timestr = time.strftime("%Y%m%d-%H%M%S")
return timestr
def lightness(pixel):
# For backwards compatibility with python2
return rgb_to_hsv(pixel[0], pixel[1], pixel[2])[2] / 255.0
def hue(pixel):
return rgb_to_hsv(pixel[0], pixel[... | satyarth/pixelsort | pixelsort/util.py | Python | mit | 1,262 |
import paho.mqtt.publish as publish
import paho.mqtt.client as mqtt
import socket
import json
from datetime import datetime
import configparser
'''
Author: GYzheng, guanggyz@gmail.com
###Server side
We have two topic, one is from client to server, the other one is from client to server
1. Server->Client : sc_topic ... | iamgyz/remote-system-control | server.py | Python | mit | 2,750 |
<<<<<<< HEAD
<<<<<<< HEAD
# Tkinter font wrapper
#
# written by Fredrik Lundh, February 1998
#
__version__ = "0.9"
import itertools
import tkinter
# weight/slant
NORMAL = "normal"
ROMAN = "roman"
BOLD = "bold"
ITALIC = "italic"
def nametofont(name):
"""Given the name of a tk named font, returns a Font repre... | ArcherSys/ArcherSys | Lib/tkinter/font.py | Python | mit | 19,973 |
# -*- coding: utf-8 -*-
"""
UploadRobot test.
These tests write to the wiki.
"""
#
# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
from __future__ import absolute_import, division, unicode_literals
import os
from pywikibot.specialbots import UploadRobot
from tests import join_i... | PersianWikipedia/pywikibot-core | tests/uploadbot_tests.py | Python | mit | 1,769 |
import logging
from datetime import datetime
from openpyxl import Workbook
from django.http import HttpResponse
from django.shortcuts import redirect, reverse
from django.views.generic import CreateView, UpdateView, TemplateView
from braces.views import StaffuserRequiredMixin
from mysite.common import Button, LinkB... | ianastewart/cwltc-admin | public/views/enquiry_views.py | Python | mit | 3,800 |
from keras.preprocessing.image import load_img, img_to_array
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
from keras.applications import vgg16
from keras import backend as K
from keras.layers import Input
def preprocess_image(image_path,img_height,img_width):
img = load_img(image_path, target_size=... | telecombcn-dl/2017-cfis | sessions/dream.py | Python | mit | 2,614 |
#!/usr/bin/env python
# Copyright (c) 2008-14 Qtrac Ltd. All rights reserved.
# This program or module 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
# version 3 of the Lic... | manashmndl/LearningPyQt | pyqt/chap05/numberformatdlg2.py | Python | mit | 4,502 |