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/env python
# -*- coding: UTF-8 -*-
#
# db.py
#
# Copyright (c) 2014
# Author: Claudio Driussi <claudio.driussi@gmail.com>
#
import sqlalchemy as sa
import copy
# sqlalchemy recognized types
base_types = {
'integer': sa.Integer,
'autoinc': sa.Integer,
'bool': sa.Boolean,
'char': sa.CHAR,
... | claudiodriussi/DynaQ | dynaq/db.py | Python | lgpl-3.0 | 18,697 |
from notifiers.base import BaseNotifier
from utils.utils import SettingManager
import requests
import re
class OpenSenseMapNotifier(BaseNotifier):
def send(self, notifier, subscriber, measurement):
sensebox_id = notifier.get_setting("sensebox_id")
sensor_id = subscriber.get_setting("sensor_id")
if sensebox_id ... | JanVan01/gwot-physical | notifiers/opensensemap.py | Python | lgpl-3.0 | 1,489 |
import hashlib
import sys
import binascii
import re
import os
import sys, os.path
localdir = repr(os.path.dirname(os.path.realpath(sys.argv[0])))
localdir = localdir.replace("\\\\","/")
localdir = localdir.replace("\'","")
def ascii2hex(char):
return hex(ord(char))[2:].upper()
def thomson_calc(... | GeorgeGkas/WifiFactoryPass-GreekTool | wifitools/speed_touch.py | Python | lgpl-3.0 | 1,873 |
#!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import sys
import re
import os
import shutil
import zipfile
"""Copy Special exercise
"""
""... | ermanno-pirotta/playground | google-python-exercises/copyspecial/copyspecial.py | Python | lgpl-3.0 | 2,723 |
#! /usr/bin/python
import boto3
import argparse
import sys
import inspect
import getpass
import os.path
import time
from os.path import expanduser
# Set up acceptable arguments
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument("-u","--up", nargs='+', help="List of EC2 ids to bring up... | V3ckt0r/Quickspin | Quickspin/quickspin.py | Python | lgpl-3.0 | 8,275 |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'yinzishao'
import re
from scrapy.exceptions import CloseSpider
import scrapy
from bs4 import BeautifulSoup
import logging
from thepaper.items import NewsItem
import json
logger = logging.getLogger("TravelWeeklyChinaSpider")
from thepaper.settings import *
clas... | yinzishao/NewsScrapy | thepaper/thepaper/spiders/travelweeklychina_spider.py | Python | lgpl-3.0 | 8,246 |
# -*- conding:utf-8 -*-
__author__ = 'mayi'
# How to read from an Excel using xlrd module
import xlrd
xls_file = "name.xls"
book = xlrd.open_workbook(xls_file)
sheet1 = book.sheet_by_index(0)
# # 获得指定索引的sheet名
# sheet1_name = book.sheet_names()[0]
# print(sheet1_name)
# # 通过sheet名字获得sheet对象
# sheet1 = book.sheet_by_nam... | WZQ1397/automatic-repo | project/excel/excel_read.py | Python | lgpl-3.0 | 633 |
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2017 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import functools
from gevent import lock
from bliss.config.conductor.client import Lock
from bliss.config.channels import Cache
from bli... | tiagocoutinho/bliss | bliss/common/shutter.py | Python | lgpl-3.0 | 10,215 |
'''
restlite: REST + Python + JSON + XML + SQLite + authentication.
http://code.google.com/p/restlite
Copyright (c) 2009, Kundan Singh, kundan10@gmail.com. All rights reserved.
License: released under LGPL (Lesser GNU Public License).
This light-weight module allows quick prototyping of web services using the... | lbovet/platane | restlite.py | Python | lgpl-3.0 | 29,388 |
from pycp2k.inputsection import InputSection
class _each52(InputSection):
def __init__(self):
InputSection.__init__(self)
self.Just_energy = None
self.Powell_opt = None
self.Qs_scf = None
self.Xas_scf = None
self.Md = None
self.Pint = None
self.Metad... | SINGROUP/pycp2k | pycp2k/classes/_each52.py | Python | lgpl-3.0 | 1,113 |
from Tribler.community.trustchain.block import TrustChainBlock
class TradeChainBlock(TrustChainBlock):
"""
Container for TradeChain block information
"""
pass
| vandenheuvel/tribler | Tribler/community/tradechain/block.py | Python | lgpl-3.0 | 177 |
# -*- coding: utf-8 -*-
# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
# GNU Lesser General Public License version 3 (see the file LICENSE).
import inspect
import textwrap
from cStringIO import StringIO
from optparse import BadOptionError
from unittest import TestCase
import django
from con... | iluminite/django-configglue | django_configglue/tests/test_configglue.py | Python | lgpl-3.0 | 15,104 |
from BOX.box_lib import requests
import os
import configparser
import traceback
import functools
import threading
configfile = os.path.join(os.path.dirname(__file__), 'EpicRace.ini')
config = configparser.ConfigParser()
config.read(configfile)
def async(func):
@functools.wraps(func)
def wrapper(*args, **kwar... | Marocco2/EpicRace | update.py | Python | lgpl-3.0 | 2,289 |
import pilas
from pilas.escena import Normal
from pilas.escena import Pausa
class EscenaDeMenu(pilas.escena.Normal):
def __init__(self):
Normal.__init__(self)
def iniciar(self):
pilas.fondos.Color(pilas.colores.negro)
pilas.actores.Texto("Bienvenidos al ejemplo de escenas apiladas."... | irvingprog/pilas | pilas/ejemplos/ejemplos/escenas/escenas_apiladas.py | Python | lgpl-3.0 | 2,369 |
from pycp2k.inputsection import InputSection
class _define_region4(InputSection):
def __init__(self):
InputSection.__init__(self)
self.List = []
self.Molname = []
self.Segname = self.Molname
self.Mm_subsys = None
self.Qm_subsys = None
self._name = "DEFINE_RE... | SINGROUP/pycp2k | pycp2k/classes/_define_region4.py | Python | lgpl-3.0 | 797 |
# -*- coding: utf-8 -*-
class InvalidResource(Exception):
"""
Raised when try to create a Resource with invalid data
"""
pass
| rodynnz/python-tfstate | src/tfstate/exceptions.py | Python | lgpl-3.0 | 144 |
# encoding=utf8
import datetime
from distutils.version import StrictVersion
import hashlib
import os.path
import shutil
import socket
import sys
import time
import random
import seesaw
from seesaw.config import NumberConfigValue
from seesaw.externalprocess import ExternalProcess
from seesaw.item import ItemInterpolati... | ArchiveTeam/qwiki-discovery | pipeline.py | Python | unlicense | 7,004 |
import sys
sys.path.append('..')
import codestudio.artist as a
from nose.tools import assert_equals
from nose.tools import assert_raises
| skilstak/code-dot-org-python | tests/codestudio_tests.py | Python | unlicense | 137 |
from whiffle import wikidotapi
from util import hook
import re
import time,threading
@hook.command
def tale(inp): #this is for WL use, easily adaptable to SCP
".tale <Article Name> -- Will return first page containing exact match to Article Name"
if firstrefresh == 0: #make sure the cache actually exists
return "C... | pixeltasim/IRCBot-Pixeltasim | plugins/tale.py | Python | unlicense | 3,149 |
import random
from tsp.ga.selection import SelectionScheme
class TournamentSelection(SelectionScheme):
"""
Runs tournaments between indivduals until a sufficient number are obtained.
"""
def __init__(self):
self.tournament_size = 5
def select(self, population):
selected = []
while len(selected... | SoftlySplinter/sem6120-assign2 | tsp/ga/selection/tournament.py | Python | unlicense | 609 |
#!/usr/bin/python
# -*- coding: utf8 -*-
import csv
import argparse
import re
if __name__ == "__main__":
# Parsing arguments
parser = argparse.ArgumentParser(description='This generates a t2t bible.')
parser.add_argument('-p', '--plan', help='plan to be used',
default="nouveau-tes... | olivierkes/bible_libre | biblification_2.py | Python | unlicense | 3,439 |
from gui import playerDialog
name = "haha"
name = playerDialog().show()
print(name)
| SGover/monopoly | test1.py | Python | unlicense | 84 |
#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import copy
import gyp.input
import optparse
import os.path
import re
import shlex
import sys
import traceback
from gyp.common... | caplin/qa-browsers | nodejs/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py | Python | unlicense | 21,827 |
#!/usr/bin/env python
'''
*******************************************************************************
Description: This tool can help you determine the character
encoding of a text file by converting one line from
the file to every(?) possible character encoding.
It wri... | Alamot/code-snippets | encodings/test_encodings.py | Python | unlicense | 4,814 |
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Deleting field 'Product.comment_count'
db.delete_column(u'shop_product', u'comment_count')
# Addi... | orlenko/bccf | src/cartridge/shop/migrations/0004_auto__del_field_product_comment_count__add_field_product_comments_coun.py | Python | unlicense | 22,289 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
d = {'Michael':95, 'Henry':96, 'Emily':97}
d['Lucy'] = 94
d['Lucy'] = 91
key = (1, 2, 3)
d[key] = 98
print(d['Michael'])
d.pop('Michael')
print(d)
print('Tom' in d)
print(d.get('Tom'))
print(d.get('Tom'), -1)
s1 = set([1, 2, 2, 3, 3])
s2 = set([2, 3, 4])
s3 = set((1, 2))... | henryneu/Python | sample/dict.py | Python | apache-2.0 | 415 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Muduo
'''
FastSync
'''
from setuptools import setup, find_packages
setup(
name='FastSync',
version='0.2.0.3',
packages=find_packages(),
install_requires=[
'requests',
'watchdog',
'pycrypto',
'future',
... | iMuduo/FastSync | setup.py | Python | apache-2.0 | 690 |
# -*- coding:utf-8 -*-
from django.shortcuts import render
from django.core.urlresolvers import reverse
from ..api import router
from .utils import get_view_doc
def api_help(request):
breadcrumblist = [
('API Help', '/api'),
]
# iterate over all registered apis
api_doc_list = []
for pref... | snbuback/django_services | django_services/api/views.py | Python | apache-2.0 | 1,394 |
# -*- coding: utf-8 -*-
# Copyright (C) 2012-2013 Yahoo! 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/LICE... | Orpheus11/nile | nile/common/reflection.py | Python | apache-2.0 | 7,670 |
#
# Copyright 2011 Twitter, 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, so... | twitter/pycascading | python/pycascading/operators.py | Python | apache-2.0 | 2,199 |
# Copyright 2014 ARM Limited
#
# Licensed under the Apache License, Version 2.0
# See LICENSE file for details.
# standard library modules, , ,
import os
import errno
import shutil
import platform
import stat
def mkDirP(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.er... | bridadan/yotta | yotta/lib/fsutils.py | Python | apache-2.0 | 2,102 |
# --------------------------------------------------------
# Fully Convolutional Instance-aware Semantic Segmentation
# Copyright (c) 2017 Microsoft
# Licensed under The Apache-2.0 License [see LICENSE for details]
# Written by Haozhi Qi, Guodong Zhang, Yi Li
# --------------------------------------------------------
... | vincentlooi/FCIS | fcis/symbols/resnet_v1_101_fcis.py | Python | apache-2.0 | 79,613 |
# ==============================================================================
# Copyright [2013] [Kevin Carter]
#
# 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/l... | cloudnull/bookofnova | bookofnova/logger.py | Python | apache-2.0 | 3,372 |
# -*- coding: utf-8 -*-
from django.shortcuts import render
from .models import Vehicale, People
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser
from .serializers import PeopleSerial... | Jhougo/Ecomrest | ecomrest/search/views.py | Python | apache-2.0 | 2,408 |
# Copyright 2014 PerfKitBenchmarker 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 appli... | mateusz-blaszkowski/PerfKitBenchmarker | perfkitbenchmarker/linux_benchmarks/mysql_service_benchmark.py | Python | apache-2.0 | 33,031 |
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Part of "Nuitka", an optimizing Python compiler that is compatible and
# integrates with CPython, but also works on its own.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complianc... | kayhayen/Nuitka | nuitka/nodes/CoroutineNodes.py | Python | apache-2.0 | 4,498 |
# Copyright 2022 The Brax Authors.
#
# 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 wri... | google/brax | brax/envs/env.py | Python | apache-2.0 | 2,766 |
"""Support for Azure Event Hubs."""
from __future__ import annotations
import asyncio
import json
import logging
import time
from typing import Any
from azure.eventhub import EventData
from azure.eventhub.aio import EventHubProducerClient, EventHubSharedKeyCredential
from azure.eventhub.exceptions import EventHubErro... | kennedyshead/home-assistant | homeassistant/components/azure_event_hub/__init__.py | Python | apache-2.0 | 8,280 |
# Required environmental variables:
# * DATABASE_URL
# * MINICASH_LOCAL_DIR
# * MINICASH_SECRET_KEY
from .base import *
DEBUG = False
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipMan... | BasicWolf/minicash | src/minicash/app/settings/heroku.py | Python | apache-2.0 | 472 |
import oauth.oauth as oauth
import httplib
import json
import sys
class BaseClient:
def __init__(self, baseURL, key, secret):
self.url = baseURL
self.connection = httplib.HTTPConnection(baseURL)
self.consumer = oauth.OAuthConsumer(key, secret)
def _execute(self, httpmethod, path, body):
request = oauth.... | stackmob/stackmob-python-examples | stackmob/client.py | Python | apache-2.0 | 1,397 |
#!/usr/bin/env python
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file ... | vmthunder/volt | volt/cmd/api.py | Python | apache-2.0 | 1,550 |
from shakedown import *
def test_install_package_cli():
assert not package_installed('dcos-enterprise-cli')
install_package_and_wait('dcos-enterprise-cli')
assert package_installed('dcos-enterprise-cli')
def test_uninstall_package_cli():
assert package_installed('dcos-enterprise-cli')
uninstall_pa... | dcos/shakedown | tests/acceptance/test_dcos_package_cli.py | Python | apache-2.0 | 414 |
# Fuck you Disyer. Stealing my fucking paypal. GET FUCKED: toontown.coghq.CashbotMintGearRoom_Action00
from panda3d.core import Point3, Vec3
from toontown.coghq.SpecImports import *
GlobalEntities = {1000: {'type': 'levelMgr',
'name': 'LevelMgr',
'comment': '',
'parentEntId': 0,
'... | DedMemez/ODS-August-2017 | coghq/CashbotMintGearRoom_Action00.py | Python | apache-2.0 | 7,793 |
import uuid
from django.contrib.auth.models import User
from django.db import models
class Token(models.Model):
key = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_at = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True, db_index=True)
... | rafaelsierra/estoudebike-api | src/bike_auth/models.py | Python | apache-2.0 | 376 |
"""
TensorFlow policy class used for CQL.
"""
from functools import partial
import numpy as np
import gym
import logging
from typing import Dict, List, Type, Union
import ray
import ray.experimental.tf_utils
from ray.rllib.agents.sac.sac_tf_policy import \
apply_gradients as sac_apply_gradients, \
compute_and_... | pcmoritz/ray-1 | rllib/agents/cql/cql_tf_policy.py | Python | apache-2.0 | 15,256 |
import sys
sys.path = [".."] + sys.path
from . import TEST_DIR
from ccmlib.cluster import Cluster
CLUSTER_PATH = TEST_DIR
def test1():
cluster = Cluster(CLUSTER_PATH, "test1", cassandra_version='2.0.3')
cluster.show(False)
cluster.populate(2)
cluster.set_partitioner("Murmur3")
cluster.start()
... | EnigmaCurry/ccm | tests/test_lib.py | Python | apache-2.0 | 1,241 |
# Copyright 2017 Eayun, 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... | openstack/neutron-vpnaas | neutron_vpnaas/services/vpn/service_drivers/driver_validator.py | Python | apache-2.0 | 1,000 |
import unittest
from os import mkdir
from os.path import exists
from shutil import rmtree
from whoosh import fields, index, qparser, store, writing
class TestIndexing(unittest.TestCase):
def make_index(self, dirname, schema):
if not exists(dirname):
mkdir(dirname)
st = store.FileStorag... | tallstreet/Whoosh-AppEngine | tests/test_indexing.py | Python | apache-2.0 | 11,352 |
from django.db import models, migrations
def update_last_modify_timestamp(apps, schema_editor):
Chat = apps.get_model('chat', 'Chat')
for chat in Chat.objects.all():
if not chat.last_modify_timestamp:
last_msg = chat.message_set.all().order_by('-timestamp').first()
if last_msg:... | cjlee112/socraticqs2 | mysite/chat/migrations/0011_auto_20170614_0341.py | Python | apache-2.0 | 636 |
#
# 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... | dhuang/incubator-airflow | airflow/providers/tableau/example_dags/example_tableau_refresh_workbook.py | Python | apache-2.0 | 2,507 |
from .mot import MOTAccumulator
import motmetrics.lap
import motmetrics.metrics
import motmetrics.distances
import motmetrics.io
import motmetrics.utils
# Needs to be last line
__version__ = '1.1.3' | e2crawfo/dps | motmetrics/__init__.py | Python | apache-2.0 | 201 |
#!/usr/bin/env python
'''
Windows Azure external inventory script
=======================================
Generates inventory that Ansible can understand by making API request to
Windows Azure using the azure python library.
NOTE: This script assumes Ansible is being executed where azure is already
installed.
p... | pintostack/core | infrastructure/windows_azure.py | Python | apache-2.0 | 8,648 |
from __future__ import unicode_literals
import itsdangerous
import mock
import pytz
from nose.tools import * # flake8: noqa
from addons.github.models import GithubFileNode
from addons.osfstorage import settings as osfstorage_settings
from api.base.settings.defaults import API_BASE
from api_tests import utils as api_... | cwisecarver/osf.io | api_tests/files/views/test_file_detail.py | Python | apache-2.0 | 24,117 |
import json
from typing import Union, List, Dict, Any
import torch
from torch.autograd import Variable
from torch.nn.modules import Dropout
import numpy
import h5py
from overrides import overrides
from allennlp.common.file_utils import cached_path
from allennlp.common.checks import ConfigurationError
from allennlp.c... | nafitzgerald/allennlp | allennlp/modules/elmo.py | Python | apache-2.0 | 18,830 |
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | google-coral/project-keyword-spotter | mel_features.py | Python | apache-2.0 | 9,761 |
# Copyright 2016 Open Source Robotics Foundation, 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... | ros2/demos | demo_nodes_py/demo_nodes_py/topics/talker_qos.py | Python | apache-2.0 | 2,757 |
from django.conf.urls.defaults import patterns, include, url
from rest_framework.urlpatterns import format_suffix_patterns
from startups import views
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('startups.views',
# Examples:
... | PredictionIO/Demo-AngelList | backend/angellist_demo/urls.py | Python | apache-2.0 | 840 |
########
# Copyright (c) 2014 GigaSpaces Technologies Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | cloudify-cosmo/cloudify-plugins-common | cloudify/tests/test_context.py | Python | apache-2.0 | 26,770 |
# -*- coding: utf-8 -*-
from operator import attrgetter
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType
from pyangbind.lib.yangtypes import RestrictedClassType
from pyangbind.lib.yangtypes import TypedListType
from pyangbind.lib.yangtypes import YANGBool
from pyangbind.lib.yangtypes import YANGListTy... | google/gnxi | oc_config_validate/oc_config_validate/models/vlan.py | Python | apache-2.0 | 1,672 |
#!/usr/bin/env python
# -- Content-Encoding: UTF-8 --
"""
Pelix remote services: XML-RPC implementation
Based on standard package xmlrpclib
:author: Thomas Calmant
:copyright: Copyright 2020, Thomas Calmant
:license: Apache License 2.0
:version: 1.0.1
..
Copyright 2020 Thomas Calmant
Licensed under the Apa... | tcalmant/ipopo | pelix/remote/xml_rpc.py | Python | apache-2.0 | 8,341 |
# -*- coding: utf-8 -*-
import json
import os
import re
def jsonTokv():
file = open('zhihu_cookies', 'r')
try:
cookies = json.load(file)
# print len(cookies)
except ValueError,e:
print 'cache-cookie is None'
cookiesStr = ''
for key in cookies:
cookiesStr += key+'='+cookies[key]+';'
print cookiesStr[0... | liaozhida/liaozhida.github.io | _posts/pythonbak/Atest.py | Python | apache-2.0 | 1,140 |
# Copyright 2014-2016 Presslabs SRL
#
# 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 wri... | PressLabs/gitfs | tests/repository/base.py | Python | apache-2.0 | 759 |
#!/usr/bin/env python
'''
Use threads and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do this.
'''
import threading
from datetime import datetime
from netmiko import ConnectHandler
from my_devices import device_list as devices
def show_version... | ktbyers/pynet-ons-mar17 | threads_procs/threads_show_ver.py | Python | apache-2.0 | 1,188 |
#!/usr/bin/python
#
# Copyright 2015 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 a... | mbrukman/cloud-launcher | apps/cloudera/director/py/rhel6.py | Python | apache-2.0 | 1,057 |
class MinStack:
def __init__(self):
"""
initialize your data structure here.
"""
from collections import deque
self.stack = deque()
self.stack.append((None, float('inf')))
def push(self, x: int) -> None:
self.stack.append((x, min(x, self.stack[-1][1])))
... | saisankargochhayat/algo_quest | leetcode/155. Min Stack/soln.py | Python | apache-2.0 | 664 |
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: mcp/v1alpha1/resource.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from ... | istio/api | python/istio_api/mcp/v1alpha1/resource_pb2.py | Python | apache-2.0 | 3,416 |
import sys
import os
import subprocess
import time
def get_slaves():
slaves = subprocess.check_output(['cat', '/root/spark-ec2/slaves'])
return slaves.strip().split('\n')
slaves = get_slaves()
for slave in slaves:
subprocess.call(['ssh', slave, 'killall', 'iperf3'])
subprocess.call(['scp', '/root/spa... | Gaojiaqi/spark-ec2 | test_speed_master.py | Python | apache-2.0 | 789 |
#
# Author:: Noah Kantrowitz <noah@coderanger.net>
#
# Copyright 2014, Balanced, 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... | coderanger/brix | templates/legacy_region.py | Python | apache-2.0 | 3,676 |
#~*~ coding: utf-8 ~*~
from django.contrib import admin
from django.forms import CheckboxSelectMultiple
from django import forms
from django.conf import settings
from virtenviro.content.models import *
class TemplateAdmin(admin.ModelAdmin):
search_fields = ['title', 'filename']
class ContentAdminForm(forms.Mode... | Haikson/virtenviro | virtenviro/content/admin.py | Python | apache-2.0 | 5,341 |
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | google/retiming | models/kp2uv_model.py | Python | apache-2.0 | 2,722 |
import mysql.connector
from model.group import Group
from model.contact import Contact
class DbFixture:
def __init__(self, host, dbname, username, password):
self.host = host
self.dbname = dbname
self.username = username
self.password = password
self.connection = mysql.conn... | 0verchenko/Addressbook | fixture/db.py | Python | apache-2.0 | 1,388 |
# Copyright 2016 Catalyst IT Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | StackStorm/python-mistralclient | mistralclient/tests/unit/v2/test_cli_members.py | Python | apache-2.0 | 3,091 |
"""Helpers for components that manage entities."""
import asyncio
from datetime import timedelta
from itertools import chain
import logging
from homeassistant import config as conf_util
from homeassistant.setup import async_prepare_setup_platform
from homeassistant.const import (
ATTR_ENTITY_ID, CONF_SCAN_INTERVAL... | tinloaf/home-assistant | homeassistant/helpers/entity_component.py | Python | apache-2.0 | 10,538 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('artwork', '0011_auto_20160217_1921'),
]
operations = [
migrations.AlterModelOptions(
name='artwork',
... | rogerhil/flaviabernardes | flaviabernardes/flaviabernardes/artwork/migrations/0012_auto_20160831_2148.py | Python | apache-2.0 | 376 |
# Users to create/delete
users = [
{'name': 'user1', 'password': 'passwd1', 'email': 'mail@example.com',
'tenant': 'tenant1', 'enabled': True},
{'name': 'user2', 'password': 'passwd2', 'email': 'aa@example.com',
'tenant': 'tenant2', 'enabled': True},
{'name': 'user3', 'password': 'paafdssswd1', 'e... | andybondar/CloudFerry | devlab/tests/config.py | Python | apache-2.0 | 9,435 |
"""HTTP Client for asyncio."""
import asyncio
import base64
import hashlib
import json
import os
import sys
import traceback
import warnings
from multidict import CIMultiDict, MultiDict, MultiDictProxy, istr
from yarl import URL
from . import connector as connector_mod
from . import client_exceptions, client_reqrep,... | Eyepea/aiohttp | aiohttp/client.py | Python | apache-2.0 | 26,125 |
class FileInput:
"""Retrieves the contents of a file and passes them to InputSets."""
def __init__(self,inputSets,filename):
"""
@param inputSets: List of target InputSets
@param filename: Name of file to be scanned for input
"""
with open(filename,'rU') as f:
text = f.read()
for i in inputSets:
... | agold/svgchart | lib/input/FileInput.py | Python | apache-2.0 | 333 |
# Copyright (C) 2016 Scott Rome. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | srome/jacksearch | search.py | Python | apache-2.0 | 922 |
#!/usr/bin/env python
import csv
# create an empty list that will be filled with the rows of data from the CSV as dictionaries
csv_content = []
# open and loop through each line of the csv file to populate our data file
with open('aaj1945_DataS1_Egg_shape_by_species_v2.csv') as csv_file:
csv_reader = csv.DictRea... | unmrds/cc-python | .ipynb_checkpoints/eggs-checkpoint.py | Python | apache-2.0 | 1,783 |
# Copyright 2016 Internap
#
# 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, sof... | mat128/python-ubersmith-remote-module-server | ubersmith_remote_module_server/api.py | Python | apache-2.0 | 1,954 |
# cd c:\Docs\Code\lawn
# kr *.py -r -c "python manage.py test test_utils"
import logging
import os
from django.test import TestCase
from utils import LoggingFilterContext, TemporaryFileContext
class TestLoggingFilter(TestCase):
def test_filtering(self):
calls = list()
def test_fn(record):
... | marksantesson/xmldump | test_utils.py | Python | apache-2.0 | 2,650 |
# Copyright 2020 The TensorFlow Authors
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to i... | tensorflow/graphics | tensorflow_graphics/geometry/deformation_energy/as_conformal_as_possible.py | Python | apache-2.0 | 9,050 |
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | googleapis/python-automl | samples/beta/list_models.py | Python | apache-2.0 | 1,782 |
# from server.utility.service_utility import count_total_page | bingweichen/GOKU | backend/server/utility/__init__.py | Python | apache-2.0 | 61 |
# Copyright (c) 2019 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/incubate/fleet/base/role_maker.py | Python | apache-2.0 | 45,318 |
# coding: utf-8
"""
Wavefront REST API Documentation
<p>The Wavefront REST API enables you to interact with Wavefront servers using standard REST API tools. You can use the REST API to automate commonly executed operations such as automatically tagging sources.</p><p>When you make REST API calls outside the W... | wavefrontHQ/python-client | wavefront_api_client/models/integration_dashboard.py | Python | apache-2.0 | 7,471 |
import json
import sure # noqa # pylint: disable=unused-import
import moto.server as server
from moto import mock_timestreamwrite
@mock_timestreamwrite
def test_timestreamwrite_list():
backend = server.create_backend_app("timestream-write")
test_client = backend.test_client()
headers = {"X-Amz-Target":... | spulec/moto | tests/test_timestreamwrite/test_server.py | Python | apache-2.0 | 514 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('players', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='player',
name='last_upd... | robrocker7/h1z1map | server/players/migrations/0002_player_last_updated.py | Python | apache-2.0 | 442 |
# -*- test-case-name: calendarserver.tap.test.test_caldav -*-
##
# Copyright (c) 2005-2014 Apple 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.apach... | trevor/calendarserver | calendarserver/tap/util.py | Python | apache-2.0 | 38,773 |
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
# 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/LICEN... | HybridF5/jacket | jacket/storage/backup/rpcapi.py | Python | apache-2.0 | 4,652 |
from flask import current_app as app, render_template, request, redirect, jsonify, url_for, Blueprint
from CTFd.utils import admins_only, is_admin, unix_time, get_config, \
set_config, sendmail, rmdir, create_image, delete_image, run_image, container_status, container_ports, \
container_stop, container_start, g... | mschwager/CTFd | CTFd/admin/challenges.py | Python | apache-2.0 | 7,890 |
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2013 Rackspace, 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
#
#... | jessicalucci/TaskManagement | taskflow/tests/unit/test_distributed_translator.py | Python | apache-2.0 | 3,987 |
from __future__ import division, print_function
from hscom import __common__
(print, print_, print_on, print_off,
rrr, profile) = __common__.init(__name__, '[hs]')
import sys
# Standard
import os
from os.path import exists, join, split, relpath
from itertools import izip
import shutil
import datetime
# Science
import ... | SU-ECE-17-7/hotspotter | hotspotter/HotSpotterAPI.py | Python | apache-2.0 | 39,134 |
"""
saltrepo
~~~~~~~~
SaltStack Repository Sphinx directives
"""
def source_read_handler(app, docname, source):
if "|repo_primary_branch|" in source[0]:
source[0] = source[0].replace(
"|repo_primary_branch|", app.config.html_context["repo_primary_branch"]
)
def setup(app... | saltstack/salt | doc/_ext/saltrepo.py | Python | apache-2.0 | 498 |
#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
"""Mimic pyquick exercise -- optional extra exercise.
Google's Python Class
Read in the ... | sanaldavis/Google-Python-Exercies | basic/mimic.py | Python | apache-2.0 | 2,511 |
from pyramid.view import view_config, view_defaults
from phoenix.views import MyView
@view_defaults(permission='view', layout='default')
class Details(MyView):
def __init__(self, request):
super(Details, self).__init__(request, name='job_details', title='Job Details')
self.tab = self.request.matc... | bird-house/pyramid-phoenix | phoenix/monitor/views/details.py | Python | apache-2.0 | 711 |
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | hpcloud-mon/python-monasca-events | monasca_events/v2_0/__init__.py | Python | apache-2.0 | 679 |
# coding=utf-8
# Copyright 2019 The SEED Authors
# 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... | google-research/seed_rl | mujoco/toy_env.py | Python | apache-2.0 | 4,588 |
import copy
import confu.schema
import vaping
import vaping.config
import vaping.io
from vaping.plugins import PluginConfigSchema
try:
import vodka
import vodka.data
except ImportError:
pass
try:
import graphsrv
import graphsrv.group
except ImportError:
graphsrv = None
def probe_to_graphsr... | 20c/vaping | src/vaping/plugins/vodka.py | Python | apache-2.0 | 3,075 |
# Copyright 2014 The Oppia 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 applicable ... | AllanYangZhou/oppia | core/domain/email_manager_test.py | Python | apache-2.0 | 78,772 |