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 |
|---|---|---|---|---|---|---|
"""Tests for the Quotes app."""
import pytest
from django.core import exceptions
from . import models
@pytest.mark.django_db
def test_quote_similarity_pk_order():
"""Pairs of quotes must be ordered by PK."""
# Small/big in terms of their IDs.
small_quote = models.Quote.objects.create(content='foo', pk=5... | dan-passaro/django-recommend | simplerec/quotes/tests.py | Python | mit | 2,071 | 0 |
import pyaf.Bench.TS_datasets as tsds
import tests.artificial.process_artificial_dataset as art
art.process_dataset(N = 32 , FREQ = 'D', seed = 0, trendtype = "LinearTrend", cycle_length = 5, transform = "RelativeDifference", sigma = 0.0, exog_count = 0, ar_order = 0); | antoinecarme/pyaf | tests/artificial/transf_RelativeDifference/trend_LinearTrend/cycle_5/ar_/test_artificial_32_RelativeDifference_LinearTrend_5__0.py | Python | bsd-3-clause | 273 | 0.084249 |
# Copyright (C) 2017 Gerrit Addiks <gerrit@addiks.net>
# https://github.com/addiks/gedit-phpide
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your o... | addiks/gmattermost | src/Application.py | Python | gpl-3.0 | 3,930 | 0.003562 |
# coding=utf-8
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from qa.models import Question, Answer
class AskForm(forms.Form):
title = forms.CharField(max_length=1024, label="Заголовок вопроса")
text = forms.CharField(widget=forms... | a-shar/web_tech | ask/qa/forms.py | Python | bsd-3-clause | 1,986 | 0.002672 |
######## Script to convert IRS spectra into pseudophotometric
######## datapoints for modeling the TDs
import asciitable
import numpy as np
import matplotlib.pyplot as plt
import pyfits
from scipy import interpolate
def remove_duplicates_func(seq):
""" This function takes a list and returns
the same without d... | alvaroribas/modeling_TDs | data_converter.py | Python | mit | 7,982 | 0.017665 |
# -*- coding: utf-8 -*-
"""
kintone上のデータを、バックアップを取ってから一括アップデートするスクリプト
オプション指定なし→ローカルキャッシュを用いてDry Run
-r(--real) →最新のデータを取得してバックアップし、更新
-f(--from-backup) →-rで問題が起きたとき用。バックアップを指定して、そのデータを元に更新する。
"""
from cache import get_all, get_app
import time
import argparse
from render import pretty
def concat_lines(x, y):
if... | mitou/meikan | updater.py | Python | mit | 3,661 | 0.001173 |
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import os
from math import sqrt
from os.path import expanduser
def extract_patches(path, filename, out_path, patch_size, stride, visualize):
img = mpimg.imread(path+filename)
nRows, nCols, nColor = img.shape
psx, psy = p... | shengshuyang/StanfordCNNClass | shadow_project/extract_patches.py | Python | gpl-3.0 | 1,314 | 0.010654 |
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without eve... | rkashapov/buildbot | master/buildbot/changes/github.py | Python | gpl-2.0 | 10,700 | 0.000093 |
"""Translate generators test."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import shutil
import tarfile
import tensorflow as tf
from data_generators import text_problems
from data_generators import translate
class TranslateTest(tf.test.Te... | mlperf/training_results_v0.6 | Google/benchmarks/transformer/implementations/tpu-v3-512-transformer/transformer/data_generators/translate_test.py | Python | apache-2.0 | 2,128 | 0.007049 |
# -*- coding: utf-8 -*-
#
# Phaser Editor documentation build configuration file, created by
# sphinx-quickstart on Thu May 25 08:35:14 2017.
#
# 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.... | boniatillo-com/PhaserEditor | docs/v2/conf.py | Python | epl-1.0 | 4,869 | 0.001643 |
from rdflib import URIRef
class Serializer(object):
def __init__(self, store):
self.store = store
self.encoding = "UTF-8"
self.base = None
def serialize(self, stream, base=None, encoding=None, **args):
"""Abstract method"""
def relativize(self, uri):
base = self.b... | aaronsw/watchdog | vendor/rdflib-2.4.0/rdflib/syntax/serializers/__init__.py | Python | agpl-3.0 | 449 | 0.004454 |
#!/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 | 0.027283 |
from .registry import ( # noqa
register_network, network_for_netcode, network_codes, network_prefixes,
network_name_for_netcode, subnet_name_for_netcode, full_network_name_for_netcode,
wif_prefix_for_netcode, address_prefix_for_netcode, pay_to_script_prefix_for_netcode,
prv32_prefix_for_netcode, pub32... | shivaenigma/pycoin | pycoin/networks/__init__.py | Python | mit | 426 | 0.004695 |
import pygame
class StartBlock(pygame.sprite.Sprite):
def __init__(self, pos = [0,0]):
pygame.sprite.Sprite.__init__(self, self.containers)
self.image = pygame.image.load("Art/EnterBlock.png")
self.rect = self.image.get_rect()
self.place(pos)
self.living = True
def place(self, pos):
self.rect.topleft ... | KRHS-GameProgramming-2014/Arkansas-Smith | StartBlock.py | Python | bsd-2-clause | 390 | 0.087179 |
#!/usr/bin/python
#
# Copyright (C) Citrix Systems Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; version 2.1 only.
#
# This program is distributed in the hope that it will be u... | pritha-srivastava/sm | drivers/lvhdutil.py | Python | lgpl-2.1 | 13,256 | 0.005432 |
while(True):
n=int(input())
if n==-1:
break
elif n==0:
print("0")
else:
print(n-1)
| h31nr1ch/Mirrors | c/OtherProblems/patinhos-2334.py | Python | gpl-3.0 | 123 | 0.02439 |
# Copyright (C) 2017 Sarah Parisot <s.parisot@imperial.ac.uk>, , Sofia Ira Ktena <ira.ktena@imperial.ac.uk>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
... | parisots/population-gcn | fetch_data.py | Python | gpl-3.0 | 2,398 | 0.00417 |
"""
The commands module contains the base definition for
a generic Qubole command and the implementation of all
the specific commands
"""
from qds_sdk.qubole import Qubole
from qds_sdk.resource import Resource
from qds_sdk.exception import ParseError
from qds_sdk.account import Account
from qds_sdk.util import GentleO... | yogesh2021/qds-sdk-py | qds_sdk/commands.py | Python | apache-2.0 | 47,582 | 0.003363 |
"""DO NOT MODIFY. Auto-generated by build_frontend script."""
CORE = "7d80cc0e4dea6bc20fa2889be0b3cd15"
UI = "805f8dda70419b26daabc8e8f625127f"
MAP = "c922306de24140afd14f857f927bf8f0"
DEV = "b7079ac3121b95b9856e5603a6d8a263"
| deisi/home-assistant | homeassistant/components/frontend/version.py | Python | mit | 226 | 0 |
# -*- 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):
# Adding field 'Video2013.created'
db.add_column('videos_video2013', 'created',
self.g... | mozilla/firefox-flicks | flicks/videos/migrations/0020_auto__add_field_video2013_created.py | Python | bsd-3-clause | 7,284 | 0.008375 |
import discord
from discord.ext import commands
from sys import argv
class Memes:
"""
Meme commands
"""
def __init__(self, bot):
self.bot = bot
print('Addon "{}" loaded'.format(self.__class__.__name__))
async def _meme(self, ctx, msg):
author = ctx.message.author
if... | T3CHNOLOG1C/Kurisu | addons/memes.py | Python | apache-2.0 | 7,307 | 0.001096 |
########################### 1. 導入所需模組
import cherrypy
import os
########################### 2. 設定近端與遠端目錄
# 確定程式檔案所在目錄, 在 Windows 有最後的反斜線
_curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
# 設定在雲端與近端的資料儲存目錄
if 'OPENSHIFT_REPO_DIR' in os.environ.keys():
# 表示程式在雲端執行
download_root_dir = os.environ['OP... | 2014c2g12/c2g12 | wsgi/w2/c2_w2.py | Python | gpl-2.0 | 9,606 | 0.005416 |
# Copyright 2015 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... | keras-team/keras | keras/initializers/__init__.py | Python | apache-2.0 | 7,577 | 0.007523 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# Copyright (C) 2004-2012 Micronaet srl. All Rights Reserved
# d$
#
# This pr... | Micronaet/micronaet-addons-private | task_manager/wizard/wizard_report.py | Python | agpl-3.0 | 11,463 | 0.015354 |
# Copyright (C) 2010-2011 Richard Lincoln
#
# 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, publish... | rwl/PyCIM | CIM14/IEC61968/Customers/CustomerAccount.py | Python | mit | 3,833 | 0.002087 |
from gtrackcore.track.core.GenomeRegion import GenomeRegion
from gtrackcore.util.CommonConstants import BINARY_MISSING_VAL
from gtrackcore.util.CommonFunctions import isNan
from gtrackcore.util.CustomExceptions import NotSupportedError
class GenomeElement(GenomeRegion):
@staticmethod
def createGeFromTrackEl(tr... | sveinugu/gtrackcore | gtrackcore/input/core/GenomeElement.py | Python | gpl-3.0 | 7,445 | 0.009268 |
"""
Video Privacy Enhancer
--------------------------
Authored by Jacob Levernier, 2014
Released under the GNU AGPLv3
For more information on this plugin, please see the attached Readme.md file.
"""
"""
SETTINGS
"""
# Do not use a leading or trailing slash below (e.g., use "images/video-thumbnails"):
output_direct... | gw0/pelican-plugins | video_privacy_enhancer/video_privacy_enhancer.py | Python | agpl-3.0 | 7,716 | 0.008683 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2012, Luis Alberto Perez Lazaro <luisperlazaro@gmail.com>
# Copyright: (c) 2015, Jakub Jirutka <jakub@jirutka.cz>
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future... | rosmo/ansible | lib/ansible/modules/files/patch.py | Python | gpl-3.0 | 7,109 | 0.002532 |
# 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... | bolkedebruin/airflow | tests/providers/apache/livy/operators/test_livy.py | Python | apache-2.0 | 6,889 | 0.003048 |
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from urlparse import parse_qs
from frappe.twofactor import get_qr_svg_code
def get_context(context):
context.no_cache = 1
context.qr_code_us... | bohlian/frappe | frappe/www/qrcode.py | Python | mit | 1,245 | 0.026506 |
import tensorflow as tf
import os
def create_single_queue(bucket_id, filename, batch_size, buckets):
"""
Return a shuffle_queue which output element from {bucket_id} bucket
:param bucket_id: int
:param filename: str
:param batch_size: int
:param buckets: list
:return:
"""
file_name... | XefPatterson/INF8225_Project | Model/queues.py | Python | mit | 3,465 | 0.001154 |
# -*- coding: utf-8 -*-
'''
saltpylint.checkers
~~~~~~~~~~~~~~~~~~~~
Works around older astroid versions
'''
# Import python libs
from __future__ import absolute_import
# Import pylint libs
import astroid
from pylint.checkers import BaseChecker as _BaseChecker
# Imported to avoid needing a separate import... | saltstack/salt-pylint | saltpylint/checkers.py | Python | apache-2.0 | 646 | 0.001548 |
# -*- coding: utf-8 -*-
#
from rest_framework import serializers
from django.utils.translation import ugettext_lazy as _
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from perms.models import AssetPermission, Action
__all__ = [
'AssetPermissionSerializer',
'ActionsField',
]
class Actio... | skyoo/jumpserver | apps/perms/serializers/asset/permission.py | Python | gpl-2.0 | 2,536 | 0.000394 |
# -*- encoding: utf-8 -*-
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import unittest
import infra_libs
DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
class ... | endlessm/chromium-browser | third_party/chromite/third_party/infra_libs/test/utils_test.py | Python | bsd-3-clause | 1,350 | 0.006667 |
import os
from invoke import task
WHEELHOUSE_PATH = os.environ.get('WHEELHOUSE')
def monkey_patch(ctx):
# Force an older cacert.pem from certifi v2015.4.28, prevents an ssl failure w/ identity.api.rackspacecloud.com.
#
# SubjectAltNameWarning: Certificate for identity.api.rackspacecloud.com has no `subj... | TomBaxter/waterbutler | tasks.py | Python | apache-2.0 | 3,064 | 0.002937 |
# This file is part of Peach-Py package and is licensed under the Simplified BSD license.
# See license.rst for the full text of the license.
from peachpy.x86_64 import *
from peachpy import *
matrix = Argument(ptr(float_))
with Function("transpose4x4_opt", (matrix,)):
reg_matrix = GeneralPurposeRegister64()
... | silky/PeachPy | examples/nmake/transpose4x4-opt.py | Python | bsd-2-clause | 1,848 | 0.000541 |
# coding: utf-8
from .dvr_base import DVRBase
import api
import struct
from io import BytesIO
from tornado import gen
@gen.engine
def call_dvr_cmd(dvr_reader, func, *args, callback, **kwargs):
stream = yield gen.Task(api.connect, dvr_reader.host, dvr_reader.port)
if stream:
def on_result(data):
... | BradburyLab/show_tv | show_tv/app/models/dvr_reader.py | Python | gpl-3.0 | 3,838 | 0.003672 |
import bisect
import difflib
import sys
import warnings
import rope.base.oi.doa
import rope.base.oi.objectinfo
import rope.base.oi.soa
from rope.base import ast, exceptions, taskhandle, utils, stdmods
from rope.base.exceptions import ModuleNotFoundError
from rope.base.pyobjectsdef import PyModule, PyPackage, PyClass
i... | JetChars/vim | vim/bundle/python-mode/pymode/libs3/rope/base/pycore.py | Python | apache-2.0 | 15,520 | 0.000451 |
from fframework import asfunction
from moviemaker3.stacks.stack import Stack
class WeightedStack(Stack):
"""Elements in the WeightedStack should return (*weight*, *layer*);
*layer* and *weight* are extracted by indexing (tuple assignment). You
might use ``fframework.compound()`` to generate tuple Functi... | friedrichromstedt/moviemaker3 | moviemaker3/stacks/weighted.py | Python | mit | 1,580 | 0.00443 |
##
## For help on setting up your machine and configuring this TestScript go to
## http://docs.bitbar.com/testing/appium/
##
import os
import time
import unittest
from time import sleep
from appium import webdriver
from device_finder import DeviceFinder
def log(msg):
print (time.strftime("%H:%M:%S") + ": " + msg... | aknackiron/testdroid-samples | appium/sample-scripts/python/testdroid_ios.py | Python | apache-2.0 | 5,790 | 0.0038 |
import unittest
from golem.network.p2p.node import Node
def is_ip_address(address):
"""
Check if @address is correct IP address
:param address: Address to be checked
:return: True if is correct, false otherwise
"""
from ipaddress import ip_address, AddressValueError
try:
# will rai... | Radagast-red/golem | tests/golem/network/p2p/test_node.py | Python | gpl-3.0 | 1,163 | 0 |
import math
from service.fake_api_results import ALL_TITLES, OFFICIAL_COPY_RESULT, SELECTED_FULL_RESULTS
SEARCH_RESULTS_PER_PAGE = 20
def get_title(title_number):
return SELECTED_FULL_RESULTS.get(title_number)
def _get_titles(page_number):
nof_results = len(ALL_TITLES)
number_pages = math.ceil(nof_resu... | LandRegistry/drv-flask-based-prototype | service/api_client.py | Python | mit | 898 | 0.001114 |
"""
Component to interface with various media players.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/media_player/
"""
import asyncio
from datetime import timedelta
import functools as ft
import hashlib
import logging
import os
from random import Syste... | eagleamon/home-assistant | homeassistant/components/media_player/__init__.py | Python | apache-2.0 | 28,502 | 0.000035 |
#!/usr/bin/env python3
import sys
import click
from boadata import __version__
from boadata.cli import try_load, try_apply_sql, qt_app
@click.command()
@click.version_option(__version__)
@click.argument("uri")
@click.option("-s", "--sql", required=False, help="SQL to run on the object.")
@click.option("-t", "--type... | janpipek/boadata | boadata/commands/boaview.py | Python | mit | 911 | 0.001098 |
# -*- coding: utf-8 -*-
# Copyright 2017 KMEE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from __future__ import division, print_function, unicode_literals
from odoo import fields, models
class FinancialDocumentType(models.Model):
_name = b'financial.document.type'
_description = 'Financ... | thinkopensolutions/l10n-brazil | financial/models/financial_document_type.py | Python | agpl-3.0 | 599 | 0 |
"""Convenience Validations for working with Cassandra"""
from fabric.operations import run
from alarmageddon.validations.validation import Priority
from alarmageddon.validations.ssh import SshValidation
def _get_percentage(text):
"""Converts strings like '12.2' or '32.4%' into floating point numbers."""
tex... | curtisallen/Alarmageddon | alarmageddon/validations/cassandra.py | Python | apache-2.0 | 4,308 | 0.001625 |
#########################
# Simple netcdf plotter #
#########################
# Needed modules
import vcs, sys, cdms
# Arguments
if len(sys.argv) < 3:
print 'Usage: python quickview.py <filename> <varname>'
sys.exit(1)
filename = sys.argv[1]
varname = sys.argv[2]
# Open netcdf file
f=cdms.open(filename)
# Read ou... | stefraynaud/spanlib | scripts/quickview.py | Python | lgpl-2.1 | 398 | 0.017588 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018-2019 NVIDIA CORPORATION. All rights reserved.
from bisect import bisect_right
import torch
# FIXME ideally this would be achieved with a CombinedLRScheduler,
# separating MultiStepLR with WarmupLR
# but the current LRSchedul... | mlperf/training_results_v0.6 | NVIDIA/benchmarks/maskrcnn/implementations/pytorch/maskrcnn_benchmark/solver/lr_scheduler.py | Python | apache-2.0 | 2,161 | 0.000925 |
"""
Tests for the Paver commands for updating test databases and its utility methods
"""
import os
import shutil
import tarfile
from tempfile import mkdtemp
from unittest import TestCase
import boto
from mock import call, patch, Mock
from pavelib import database
from pavelib.utils import db_utils
from pavelib.utils... | msegado/edx-platform | pavelib/paver_tests/test_database.py | Python | agpl-3.0 | 8,779 | 0.002962 |
#
# Test PM force parallelisation:
# check force does not depend on number of MPI nodes
import fs
import numpy as np
import h5py
import pm_setup
# read reference file
# $ python3 create_force_h5.py to create
file = h5py.File('force_%s.h5' % fs.config_precision(), 'r')
ref_id = file['id'][:]
ref_force = file['f'][:]
... | junkoda/fs2 | test/test_pm_force.py | Python | gpl-3.0 | 990 | 0 |
"""Auto-generated file, do not edit by hand. LY metadata"""
from ..phonemetadata import NumberFormat, PhoneNumberDesc, PhoneMetadata
PHONE_METADATA_LY = PhoneMetadata(id='LY', country_code=None, international_prefix=None,
general_desc=PhoneNumberDesc(national_number_pattern='1\\d{2}', possible_length=(3,)),
em... | gencer/python-phonenumbers | python/phonenumbers/shortdata/region_LY.py | Python | apache-2.0 | 556 | 0.008993 |
'''
|--------------------------------------------------------------------------
|
| Jam arrange: GUI linked to arrangement algorithm
| Author: Victor Motha
| Copyright 2016
| Objective: Sort through audio files and sort them according to artist names.
| Current stable version: 0.0.4
|
'''
'''
|------------------------... | jamarrange/sort | build/fileSort/Arranger.py | Python | mit | 12,285 | 0.003093 |
from __future__ import print_function, division, absolute_import
# Copyright (c) 2017 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNES... | Lorquas/subscription-manager | test/rhsmlib_test/test_products.py | Python | gpl-2.0 | 14,073 | 0.001279 |
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
... | ivngithub/testproject | config.py | Python | mit | 1,559 | 0.000641 |
import os
import sys
import logging
__all__ = [
'clear_root_handlers',
'setup_console_logging',
'setup_file_logging'
]
DEFAULT_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S'
DEFAULT_LOG_FORMAT = '%(asctime)s [%(levelname)s] %(message)s'
DEFAULT_LOG_LEVEL = logging.INFO
class NullHandler(logging.Handler):
def ... | m00dawg/holland | holland/core/log.py | Python | bsd-3-clause | 1,274 | 0.007849 |
# Copyright (C) 2010-2012 Red Hat, Inc.
# This work is licensed under the GNU GPLv2 or later.
# To test "virsh hostname" command
from libvirttestapi.utils import process
required_params = ()
optional_params = {}
VIRSH_HOSTNAME = "virsh hostname"
def hostname(params):
"""check virsh hostname command
"""
... | libvirt/libvirt-test-API | libvirttestapi/repos/domain/hostname.py | Python | gpl-2.0 | 1,070 | 0.000935 |
# -*- coding: utf-8 -*-
# Copyright (c) 2014 Ludo Visser
#
# task-chrono is distributed under the terms and conditions of the MIT license.
# The full license can be found in the LICENSE file.
import numpy
import os
import StringIO as sio
# Useful enumeration class
class Enum:
def __init__(self, *sequential, **n... | lcvisser/task-chrono | util.py | Python | mit | 4,240 | 0.004953 |
# Author: Samuel Genheden, samuel.genheden@gmail.com
"""
Program to build lipids from a template, similarly to MARTINI INSANE
Is VERY experimental!
"""
import argparse
import os
import xml.etree.ElementTree as ET
import numpy as np
from sgenlib import pdb
class BeadDefinition(object):
def __init__(self):
... | SGenheden/Scripts | Membrane/build_lipid.py | Python | mit | 3,765 | 0.007437 |
import sqlalchemy as sa
# Define a version number for the database generated by these writers
# Increment this version number any time a change is made to the schema of the
# assets database
# NOTE: When upgrading this remember to add a downgrade in:
# .asset_db_migrations
ASSET_DB_VERSION = 7
# A frozenset of the n... | quantopian/zipline | zipline/assets/asset_db_schema.py | Python | apache-2.0 | 4,743 | 0 |
# https://app.codesignal.com/arcade/code-arcade/corner-of-0s-and-1s/b5z4P2r2CGCtf8HCR
def killKthBit(n, k):
# Use bit operators to turn off the k-th bit from the right.
# First create a value with the bit at the position turned on
# and everything else off. Then flip that value so all bits
# are 1 excep... | zubie7a/Algorithms | CodeSignal/Arcade/The_Core/Level_03_Corner_Of_Zeros_And_Ones/017_Kill_Kth_Bit.py | Python | mit | 492 | 0 |
# -*- coding: utf-8 -*-
"""
TDDA constraint discovery and verification is provided for a number
of DB-API (PEP-0249) compliant databases, and also for a number of other
(NoSQL) databases.
The top-level functions are:
:py:func:`tdda.constraints.discover_db_table`:
Discover constraints from a single databas... | tdda/tdda | tdda/constraints/db/constraints.py | Python | mit | 17,342 | 0.000115 |
# -*- coding: utf-8 -*-
"""
pymemcache.errors
~~~~~~~~~~~~~~~~~
Exceptions base classes for pymemcache
"""
class Error(Exception):
"""Base exception for all pymemcache errors"""
class ConnectionError(Error):
"""Base class for any socket-level connection issues"""
class RequestError(Error):
... | etscrivner/pymemcache | pymemcache/errors.py | Python | bsd-3-clause | 465 | 0 |
import sqlite3
import csv
def csv_to_arr(csv_file, start=1, has_header=True):
arr = []
with open(csv_file, 'rU') as f:
reader = csv.reader(f)
arr = list(reader)
if arr == []:
return
header = ""
if has_header:
header = ','.join(arr[0])
arr = arr[start:]
return header, arr
else:
return arr[start:... | frederick623/HTI | omm/merge_csv.py | Python | apache-2.0 | 3,078 | 0.022092 |
# -*- coding: utf-8 -*-
"""
Math Render Plugin for Pelican
==============================
This plugin allows your site to render Math. It uses
the MathJax JavaScript engine.
For markdown, the plugin works by creating a Markdown
extension which is used during the markdown compilation
stage. Math therefore gets treated... | lindzey/pelican-plugins | render_math/math.py | Python | agpl-3.0 | 14,090 | 0.003123 |
# This file is distributed under the terms of the GNU General Public license.
# Copyright (C) 1999 Aloril (See the file COPYING for details).
import time
from mind.Goal import Goal
# goals for minds
def false(_): return False
def true(_): return True
class Delayed(Goal):
"""Will delay execution of sub goal... | worldforge/cyphesis | data/rulesets/basic/scripts/mind/goals/common/common.py | Python | gpl-2.0 | 3,486 | 0.002008 |
from shrubbery.authentication.contexts import AuthenticationContext, ModelAuthenticationContext
from shrubbery.authentication.exceptions import AuthenticationError, Http403 | emulbreh/shrubbery | shrubbery/authentication/__init__.py | Python | mit | 172 | 0.011628 |
#!/usr/bin/python
import sys, getopt
def main(argv):
try:
opts, args = getopt.getopt(argv,"hi:o:",["help","mpileupfile=","jfile=","snpfile=","ofile="])
except getopt.GetoptError:
print 'removeNegValuesMOD.py -i <infile> -o <output_file>'
sys.exit(2)
... | friedue/AlleleSpecific | individualScripts/removeNegValuesMOD.py | Python | mit | 2,375 | 0.025684 |
#######################################################################
# This file is part of redminelib.
#
# Copyright (C) 2011 Will Kahn-Greene
#
# redminelib is distributed under the MIT license. See the file
# COPYING for distribution details.
######################################################################... | willkg/redminelib | redminelib/tests/test716.py | Python | mit | 1,444 | 0 |
#!/usr/bin/env python3
from pathlib import Path
p = Path('.')
| qilicun/python | python3/tutorials/filepath.py | Python | gpl-3.0 | 65 | 0.015385 |
# Copyright (c) 2011, Bernhard Leiner
# Copyright (c) 2013-2018 Alexander Belchenko
# 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... | adfernandes/intelhex | intelhex/compat.py | Python | bsd-3-clause | 5,035 | 0.002383 |
"""
This file is part of xcos-gen.
xcos-gen 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.
xcos-gen is distribute... | ilia-novikov/xcos-gen | hdl_block.py | Python | gpl-3.0 | 1,461 | 0.000684 |
#!/usr/bin/env python
"""
This program decodes the Motorola SmartNet II trunking protocol from the control channel
Tune it to the control channel center freq, and it'll spit out the decoded packets.
In what format? Who knows.
Based on your AIS decoding software, which is in turn based on the gr-pager code and the... | bistromath/gr-smartnet | src/python/smartnet2decode.py | Python | gpl-3.0 | 13,591 | 0.033037 |
class Events(object):
"""
Events Enum
"""
UI_BTN_PRESSED = 100
UI_BTN_RELEASED = 101
UI_BTN_CLICKED = 102
SET_UI_BTN_STATE = 150
| rituven/winston | core/Events.py | Python | apache-2.0 | 163 | 0.006135 |
from django.contrib.auth.models import User
from localtv.tests import BaseTestCase
from localtv import models
from localtv.playlists.models import Playlist
from localtv import search
class SearchTokenizeTestCase(BaseTestCase):
"""
Tests for the search query tokenizer.
"""
def assertTokenizes(self, qu... | natea/Miro-Community | localtv/search/tests.py | Python | agpl-3.0 | 10,029 | 0.001197 |
#Graph data structure for input graph
from node import Node
class Graph:
def __init__(self, n):
self.numnodes = n
self.vertices = [] #container for nodes
self.edges = []
for i in range(0,n):
self.vertices.append(Node(i))
self.edges.append([])
self.m... | emmanuj/dials_shortest_path | graph.py | Python | mit | 1,382 | 0.015195 |
#!/usr/bin/env python
from ciscoconfparse import CiscoConfParse
def main():
cisco_cfg = CiscoConfParse("cisco_ipsec.txt")
cr_map_list = cisco_cfg.find_objects(r"^crypto map CRYPTO")
for item in cr_map_list:
print item.text
for child in item.children:
print child.text
if __name__ == "__main__":
main()
... | Paricitoi/python_4_eng | python_week1/v2/week1_ex8v2.py | Python | gpl-3.0 | 321 | 0.034268 |
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Author: Kiall Mac Innes <kiall@hpe.com>
#
# 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/... | openstack/designate | designate/quota/__init__.py | Python | apache-2.0 | 966 | 0 |
from datetime import datetime
from datetime import timezone
import singer
import urllib.request
def my_ip():
now = datetime.now(timezone.utc).isoformat()
schema = {
'properties': {
'ip': {'type': 'string'},
'timestamp': {'type': 'string', 'format': 'date-time'},
},
... | karantan/singer-getting-started | src/main.py | Python | mit | 617 | 0 |
# Copyright(C) 2011,2012,2013,2014 by Abe developers.
# DataStore.py: back end database access for Abe.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License... | Oizopower/Whitecoin-ABE | Abe/DataStore.py | Python | agpl-3.0 | 122,759 | 0.001662 |
# 211. Add and Search Word - Data structure design
#
# Design a data structure that supports the following two operations:
#
# void addWord(word)
# bool search(word)
#
# search(word) can search a literal word or a regular expression string containing
# only letters a-z or .. A . means it can represent any one letter.
#... | gengwg/leetcode | 211_add_and_search_word.py | Python | apache-2.0 | 2,673 | 0.001122 |
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | muendelezaji/workload-automation | wlauto/workloads/camerarecord/__init__.py | Python | apache-2.0 | 1,671 | 0.001197 |
#
# Code per http://blog.powerupcloud.com/2016/03/26/automating-rds-snapshots-with-aws-lambda/
#
import boto3
import botocore
import datetime
import re
SOURCE_REGION = 'us-east-1'
TARGET_REGION = 'us-west-1'
iam = boto3.client('iam')
instances = ['<instance name>'] # convert to command line argument
print('Loading f... | jdasinger/random | copy_rds.py | Python | gpl-3.0 | 1,743 | 0.004016 |
'''
More information at: http://www.pymolwiki.org/index.php/elbow_angle
Calculate the elbow angle of an antibody Fab complex and optionally draw a
graphical representation of the vectors used to determine the angle.
NOTE: There is no automatic checking of the validity of limit_l and limit_h
values or of the assignm... | demharters/git_scripts | my_elbow_angle_tcr_imgt.py | Python | apache-2.0 | 7,744 | 0.02079 |
# Define the grammar for the Pythonic Query Language.
# the smallest unit is a term
# between any two terms there can be:
# a COMMA - delimits fields and defines explicit query groups:
# a, b, c @ d>1, 2, 3
# a CONJUCTION - python in fields and acts as delimitor for conditions:
# ... | pyql/PyQL | yaccer.py | Python | gpl-3.0 | 9,082 | 0 |
import sys
from services.spawn import MobileTemplate
from services.spawn import WeaponTemplate
from resources.datatables import WeaponType
from resources.datatables import Difficulty
from resources.datatables import Options
from resources.datatables import FactionStatus
from java.util import Vector
def addTemplate(co... | ProjectSWGCore/NGECore2 | scripts/mobiles/generic/faction/imperial/imp_warant_officer_ii_1st_class_33.py | Python | lgpl-3.0 | 1,458 | 0.028121 |
#! /usr/bin/python3
import os
import shutil
import tempfile
import unittest
from ubiquity import install_misc
class InstallMiscTests(unittest.TestCase):
def setUp(self):
self.source = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.source)
self.target = tempfile.mkdtemp()
... | yolanother/ubuntumobidev_ubiquity | tests/test_install_misc.py | Python | gpl-3.0 | 4,712 | 0 |
#!/usr/bin/python
import sys
import re
import thread
import urllib
from time import sleep
from datetime import datetime, timedelta
import requests
import praw
from prawcore.exceptions import *
import irc.bot
# Begin configurable parameters
identity = { # Make sure to set these if they aren't already!
'reddit_cli... | flarn2006/TPPStreamerBot | tppsb.py | Python | mit | 10,064 | 0.029213 |
import setuptools
import io
import sys
import os.path
import subprocess
setuptools.setup(
name='jsonpath-rw',
version='1.4.0',
description='A robust and significantly extended implementation of JSONPath for Python, with a clear AST for metaprogramming.',
author='Kenneth Knowles',
author_email='ken... | pkilambi/python-jsonpath-rw | setup.py | Python | apache-2.0 | 1,220 | 0.012295 |
"""
Soft Voting/Majority Rule classifier and Voting regressor.
This module contains:
- A Soft Voting/Majority Rule classifier for classification estimators.
- A Voting regressor for regression estimators.
"""
# Authors: Sebastian Raschka <se.raschka@gmail.com>,
# Gilles Louppe <g.louppe@gmail.com>,
# ... | sergeyf/scikit-learn | sklearn/ensemble/_voting.py | Python | bsd-3-clause | 19,214 | 0.000364 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as 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 'ToIndexStore.basemodel_ptr'
db.delete_column(u'catalog_... | Makeystreet/makeystreet | woot/apps/catalog/migrations/0029_auto__del_field_toindexstore_basemodel_ptr__add_field_toindexstore_id.py | Python | apache-2.0 | 26,077 | 0.007363 |
"""Compatibility functions for Python 2 and 3."""
from __future__ import unicode_literals
import io
from django_evolution.compat import six
from django_evolution.compat.picklers import DjangoCompatUnpickler
from django_evolution.compat.six.moves import cPickle as pickle
def pickle_dumps(obj):
"""Return a pickl... | beanbaginc/django-evolution | django_evolution/compat/py23.py | Python | bsd-3-clause | 1,420 | 0 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tomato.tests
"""
import unittest
import msgpack
import time
try:
from PIL import Image
except ImportError:
import Image
from tomato.swf_processor import Swf
from tomato.exceptions_tomato import MovieClipDoesNotExist
from tomato.utils import bits_list2string, B... | buhii/tomato | tests.py | Python | mit | 3,294 | 0.002732 |
#!/usr/bin/python
#
# Copyright 2014 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
#
# Unless required b... | wubr2000/googleads-python-lib | examples/dfa/v1_20/create_spotlight_activity_group.py | Python | apache-2.0 | 2,085 | 0.004796 |
#!/usr/bin/env python -t
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Jonathan Delvaux <pyshell@djoproject.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License... | djoproject/pyshell | pyshell/utils/test/misc_test.py | Python | gpl-3.0 | 2,472 | 0 |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
from pants.backend.p... | cevaris/pants | src/python/pants/backend/python/targets/python_requirement_library.py | Python | apache-2.0 | 1,293 | 0.006187 |
#!/usr/bin/env python
# Copyright 2014-2019 The PySCF Developers. 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
#
# U... | gkc1000/pyscf | pyscf/scf/hf_symm.py | Python | apache-2.0 | 36,696 | 0.003706 |
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# ... | rdo-management/heat | heat/db/sqlalchemy/migrate_repo/versions/024_event_resource_name.py | Python | apache-2.0 | 807 | 0 |
__author__ = 'saftophobia'
| Saftophobia/shunting | data/__init__.py | Python | mit | 28 | 0.035714 |
from datetime import datetime
import urllib.request
import time
from subprocess import call
import sys
import os
retry_time = 45
# save_path = ""
def get_raw_data(path):
start = time.clock()
query = "http://export.arxiv.org/oai2?verb=ListRecords&metadataPrefix=oai_dc"
print("request: %s" % (query))
... | sciosci/nsf_data_ingestion | nsf_data_ingestion/arxiv/fetch_data_hdfs_loop.py | Python | apache-2.0 | 2,651 | 0.000754 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
... | noplay/gns3-gui | gns3/modules/dynamips/pages/frame_relay_switch_configuration_page.py | Python | gpl-3.0 | 6,628 | 0.00166 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.