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 |
|---|---|---|---|---|---|---|
# coding: utf-8
'''
Copyright (c) 2010, Alexandru Dancu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of condit... | BackupTheBerlios/kimchi | src/ui/mvc/delegate/KTableDelegate.py | Python | bsd-3-clause | 2,652 | 0.00905 |
"""
Copyright (c) 2013 Rodrigo Baravalle
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following... | rbaravalle/imfractal | imfractal/Algorithm/MFS_3D.py | Python | bsd-3-clause | 11,780 | 0.00798 |
"""
Common test utilities for courseware functionality
"""
from abc import ABCMeta, abstractmethod
from datetime import datetime, timedelta
import ddt
import six
from mock import patch
from six.moves.urllib.parse import urlencode
from lms.djangoapps.courseware.field_overrides import OverrideModulestoreFieldData
fro... | stvstnfrd/edx-platform | lms/djangoapps/courseware/testutils.py | Python | agpl-3.0 | 11,543 | 0.002512 |
# -*- coding: utf-8 -*-
# Copyright 2022 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... | googleapis/python-channel | google/cloud/channel_v1/types/entitlements.py | Python | apache-2.0 | 11,801 | 0.001271 |
# 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, softw... | google/fuzzbench | docs/reference/benchmarks.py | Python | apache-2.0 | 6,523 | 0.000307 |
# -*- coding: utf-8 -*-
{
'!langcode!': 'bg',
'!langname!': 'Български',
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN',
'"User Exceptio... | xiang12835/python_web | py2_web2py/web2py/applications/admin/languages/bg.py | Python | apache-2.0 | 35,738 | 0.020631 |
# Python modules
import gc
import os
import subprocess
import random
import re
import sys
# My module
import sysv_ipc
SKIP_SEMAPHORE_TESTS = False
SKIP_SHARED_MEMORY_TESTS = False
SKIP_MESSAGE_QUEUE_TESTS = False
# TEST_COUNT = 10
TEST_COUNT = 1024 * 100
PY_MAJOR_VERSION = sys.version_info[0]
# ps output looks l... | mruffalo/sysv_ipc | extras/memory_leak_tests.py | Python | bsd-3-clause | 20,971 | 0.000763 |
#!/usr/bin/env python
#
# ROS node to control NAO's built-in and user-installed behaviors using NaoQI
# Tested with NaoQI: 1.12
#
# Copyright (c) 2012, 2013 Miguel Sarabia
# Imperial College London
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the fo... | miguelsdc/nao_robot | nao_driver/scripts/nao_behaviors.py | Python | bsd-3-clause | 5,440 | 0.0125 |
def count(S, m, n):
table = [[0 for x in range(m)] for x in range(n+1)]
for i in range(m):
table[0][i] = 1
for i in range(1, n+1):
for j in range(m):
x = table[i - S[j]][j] if i-S[j] >= 0 else 0
y = table[i][j-1] if j >= 1 else 0
table[i][j] ... | Sunhick/hacker_rank | Algorithms/Dynamic Programming/The-Coin-Change-Problem.py | Python | mit | 496 | 0.010081 |
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | sgammon/libcloud | libcloud/compute/drivers/gandi.py | Python | apache-2.0 | 20,171 | 0.00005 |
# weaponUpgradesCpuNeedBonusPostPercentCpuLocationShipModulesRequiringMissileLauncherOperation
#
# Used by:
# Implants named like: Zainou 'Gnome' Launcher CPU Efficiency LE (6 of 6)
# Skill: Weapon Upgrades
type = "passive"
def handler(fit, container, context):
level = container.level if "skill" in context else 1... | Ebag333/Pyfa | eos/effects/weaponupgradescpuneedbonuspostpercentcpulocationshipmodulesrequiringmissilelauncheroperation.py | Python | gpl-3.0 | 517 | 0.003868 |
# Bulletproof Arma Launcher
# Copyright (C) 2017 Lukasz Taczuk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# b... | overfl0/Bulletproof-Arma-Launcher | src/utils/requests_wrapper.py | Python | gpl-3.0 | 2,188 | 0.001828 |
#!/usr/bin/env python
import os
print "Cleaning directory %s"%(os.path.realpath('.'))
rubbish_filetypes = ('h5','hdf','.dat','.pyc', '.png', '.pdf', '.tar.gz')
rubbish_startnames = ('job','logdata','Amplitude','Real','spool','pool')
choosing = raw_input("Continue [yes/anykey_for_NO] ?")
if choosing == 'yes':
print "C... | mrosenstihl/PulsePrograms | make_clean.py | Python | bsd-2-clause | 679 | 0.041237 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import timedelta
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.model
def default_... | rven/odoo | addons/sale_management/models/sale_order.py | Python | agpl-3.0 | 12,391 | 0.00347 |
from tornado.options import define, options
def load_options(config_file):
# General application settings
define('port', type=int, group='application', help='Port to run the application from.')
define('compress_response', type=bool, group='application', help='Whether or not to compress the response.')
... | fdemian/Morpheus | api/LoadOptions.py | Python | bsd-2-clause | 3,767 | 0.00876 |
from wtforms import Form, BooleanField, TextField, PasswordField, validators
import re
illegal_shortcode_names = ["admin"]
legal_shortcode_regex = "^[a-zA-Z0-9\.\_\-\~\!\$\&\'\(\)\*\,\;\=]*$"
def shortcode_validator(form, field):
if field.data is not None:
if (field.data in illegal_shortcode_names):
raise valid... | AndrewNeo/hybridius | forms.py | Python | mit | 1,328 | 0.024849 |
## READ VARIABLE FROM SEVERAL NCFILES and store subset of it as NPY
from __future__ import print_function
path = '/network/aopp/cirrus/pred/kloewer/swm_bf_cntrl/data/'
#path = '/network/aopp/cirrus/pred/kloewer/swm_back_ronew/'
import os; os.chdir(path) # change working directory
import numpy as np
from netCDF4 impor... | milankl/swm | calc/process/var_subset_last.py | Python | gpl-3.0 | 1,070 | 0.018692 |
# 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 requ... | hplustree/trove | trove/common/wsgi.py | Python | apache-2.0 | 23,631 | 0.000296 |
"""
This module provides vCard parameters that are defined by the vCard 4.0
RFC.
"""
from vcard4.parameters import BaseParameter
class Language(BaseParameter):
"""
A LANGUAGE parameter.
Example:
ROLE;LANGUAGE=tr:hoca
"""
def __init__(self, language):
super(Language, self).__init... | Crosse/vcard4 | vcard4/parameters/RFCParameters.py | Python | bsd-2-clause | 413 | 0.002421 |
import sys
from pymongo import MongoClient
# Connecting to the mongo client
client = MongoClient('localhost',27017)
# Connecting to the database
db = client['rescueHomeless']
# Connecting to the required collection
collection = db['userDB']
userEmail = sys.argv[1]
result = collection.find({'email':userEmail})
pIDs =... | Four-Stooges/Server | public/resources/scripts/latestupload.py | Python | mit | 392 | 0.012755 |
#!/usr/bin/python
#
# Copyright 2012 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... | krux/adspygoogle | examples/adspygoogle/dfp/v201204/inventory_service/create_ad_units.py | Python | apache-2.0 | 2,765 | 0.008318 |
"""Support for ZHA sirens."""
from __future__ import annotations
import functools
from typing import Any
from zigpy.zcl.clusters.security import IasWd as WD
from homeassistant.components.siren import (
ATTR_DURATION,
SUPPORT_DURATION,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SirenEntity,
)
from homeas... | rohitranjan1991/home-assistant | homeassistant/components/zha/siren.py | Python | mit | 5,710 | 0.000876 |
from vt_manager.communication.sfa.util.xrn import urn_to_hrn
from vt_manager.communication.sfa.util.method import Method
from vt_manager.communication.sfa.util.parameter import Parameter, Mixed
class reset_slice(Method):
"""
Reset the specified slice
@param cred credential string specifying the rig... | dana-i2cat/felix | vt_manager/src/python/vt_manager/communication/sfa/methods/reset_slice.py | Python | apache-2.0 | 1,080 | 0.007407 |
# coding: utf-8
"""
1. Bare-bones model
This is a basic model with only two non-primary-key fields.
"""
# Python 2.3 doesn't have set as a builtin
try:
set
except NameError:
from sets import Set as set
# Python 2.3 doesn't have sorted()
try:
sorted
except NameError:
from django.utils.itercompat import... | chuck211991/django-pyodbc | tests/basic/models.py | Python | bsd-3-clause | 15,295 | 0.001896 |
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | HubSpot/vitess | test/cluster/sandbox/sandbox_utils.py | Python | apache-2.0 | 1,777 | 0.009004 |
# ------------------------------------------------------------------------
# coding=utf-8
# ------------------------------------------------------------------------
from __future__ import absolute_import
import os
from django import forms
from django.conf import settings as django_settings
from django.contrib import... | pjdelport/feincms | feincms/module/medialibrary/modeladmins.py | Python | bsd-3-clause | 8,526 | 0.004926 |
# -*- coding: utf-8 -*- line endings: unix -*-
"""A bare-bones cross-platform Telnet server."""
# miniboa.py
# Copyright 2009 Jim Storch
# 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://w... | whutch/atria | cwmud/libs/miniboa.py | Python | mit | 35,233 | 0 |
#
# The Multiverse Platform is made available under the MIT License.
#
# Copyright (c) 2012 The Multiverse Foundation
#
# 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 restrict... | longde123/MultiversePlatform | client/Scripts/AnimationState.py | Python | mit | 2,968 | 0.012803 |
# Copyright (C) 2012 Alex Nitz, Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This p... | tdent/pycbc | pycbc/waveform/bank.py | Python | gpl-3.0 | 39,353 | 0.002338 |
#! python3
# Python 3 Image to text
# 20.07.17 fixed bugs
# require to install pillow, numpy
# pip install pillow
# pip install numpy
# -*- coding: UTF-8 -*-
from PIL import Image
import numpy as np
import random
import math
def convert(num) :
a0 = ['■','■','■','■','■','■','■','■']
a1 = ['$','#','%... | TADT1909/PythonProjects | ImageToText.py | Python | mit | 1,698 | 0.043401 |
from __future__ import absolute_import
from __future__ import division
from builtins import zip
from builtins import map
from builtins import range
from builtins import object
from past.utils import old_div
import bisect
class quadNG(object): # quadratic Newton-Gregory Interpolation
''' quadratic Ne... | sonofeft/XYmath | xymath/newtGreg2.py | Python | gpl-3.0 | 5,126 | 0.02419 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Photobooth - a flexible photo booth software
# Copyright (C) 2018 Balthasar Reuter <photobooth at re - web dot eu>
#
# 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
# t... | reuterbal/photobooth | photobooth/worker/PictureMailer.py | Python | agpl-3.0 | 3,515 | 0 |
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
def get_jenv():
import frappe
if not getattr(frappe.local, 'jenv', None):
from jinja2 import Environment, DebugUndefined
# frappe will be loaded last, so app templates wil... | aboganas/frappe | frappe/utils/jinja.py | Python | mit | 5,056 | 0.028877 |
# -*- coding: utf-8 -*-
import logging
from geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- tri par surface de faces
def sortFaces(facesToSort):
"""
tri des faces par surface
"""
logging.info('start')
surFaces = [(geompy.BasicProperties(face)[1... | FedoraScientific/salome-smesh | src/Tools/blocFissure/gmu/sortFaces.py | Python | lgpl-2.1 | 497 | 0.018109 |
# Problem:
# Write a program that enters a password (one line with any text) and
# checks if it is entered matches the phrase "s3cr3t! P @ ssw0rd".
# In case of a collision, bring "Welcome".
# In case of inconsistency "Wrong Password!"
password = input()
if password == "s3cr3t!P@ssw0rd":
print("Welcome")
else:
... | YaniLozanov/Software-University | Python/PyCharm/03.Logical checks/09.Password Guess.py | Python | mit | 348 | 0 |
# -*- coding: utf-8 -*-
from mock import patch
from unittest import TestCase
from datetime import date, timedelta
from django.http import Http404
from django.test import RequestFactory, override_settings
from fr_notices.navigation import make_preamble_nav
from regulations.generator.layers import diff_applier
from re... | 18F/regulations-site | regulations/tests/views_preamble_tests.py | Python | cc0-1.0 | 10,884 | 0 |
import base64
from hashlib import sha1
import hmac
import time
import random
from libsaas import http, port
class BasicAuth(object):
"""
Adds a Basic authentication header to each request.
"""
def __init__(self, username, password):
self.username = username
self.password = password
... | ducksboard/libsaas | libsaas/filters/auth.py | Python | mit | 6,734 | 0 |
from django import template
from django.conf import settings
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.simple_tag
@stringfilter
def get_settings_val(setting):
return getattr(settings, setting)
| MontrealCorpusTools/polyglot-server | iscan/templatetags/extra_tags.py | Python | mit | 253 | 0.003953 |
#!/usr/bin/env python
# Copyright 2012-2013 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.a... | jesusaurus/openstack-tests | swift/swiftTest.py | Python | apache-2.0 | 9,677 | 0.002273 |
# -*- coding: latin-1 -*-
#
# Copyright (C) AB Strakt
# Copyright (C) Jean-Paul Calderone
# See LICENSE for details.
"""
Simple SSL client, using blocking I/O
"""
from OpenSSL import SSL
import sys, os, select, socket
def verify_cb(conn, cert, errnum, depth, ok):
# This obviously has to be updated
print 'Got... | mhnatiuk/phd_sociology_of_religion | scrapper/build/pyOpenSSL/examples/simple/client.py | Python | gpl-2.0 | 1,260 | 0.003968 |
#coding:utf-8
import tensorflow as tf
from TFCommon.Layers import EmbeddingLayer
from TFCommon.RNNCell import LSTMCell
class HypeNet(object):
def __init__(self,word_num,word_embd_dim,pos_num,pos_embd_dim,
parse_num,parse_embd_dim,LSTM_dim,x_vector_dim,y_vector_dim,classification_dim):
se... | dongfangyixi/HypeNet-tensorflow | model.py | Python | apache-2.0 | 9,884 | 0.030763 |
from .client import GSDataFormat # noqa
from .client import GSFileMetadata # noqa
from .client import GenomeSpaceClient # noqa
from .shell import main # noqa
| gvlproject/python-genomespaceclient | genomespaceclient/__init__.py | Python | mit | 162 | 0 |
from django.contrib import admin
from api.models import (
CrawlUrls,
CrawlLinks,
)
# Register your models here.
admin.site.register(CrawlUrls)
admin.site.register(CrawlLinks) | saymedia/seosuite-dashboard-api | api/admin.py | Python | mit | 187 | 0.005348 |
# (C) Copyright 2014 Voyager Search
#
# 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 writi... | voyagersearch/voyager-py | processing/locale/make_mo_files.py | Python | apache-2.0 | 1,085 | 0.002765 |
from .. import QMessageBoxPatched as QMessageBox
from ....qt import get_qapp
from ....external.qt import QtGui
def test_main():
app = get_qapp()
w = QMessageBox(QMessageBox.Critical, "Error", "An error occurred")
w.setDetailedText("Spam")
w.select_all()
w.copy_detailed()
assert app.clipboar... | JudoWill/glue | glue/utils/qt/tests/test_qmessagebox_widget.py | Python | bsd-3-clause | 357 | 0 |
import rdtest
import renderdoc as rd
class VK_CBuffer_Zoo(rdtest.TestCase):
def get_capture(self):
return rdtest.run_and_capture("demos_x64", "VK_CBuffer_Zoo", 5)
def check_capture(self):
draw = self.find_draw("Draw")
self.check(draw is not None)
self.controller.SetFrameEven... | googlestadia/renderdoc | util/test/tests/Vulkan/VK_CBuffer_Zoo.py | Python | mit | 31,170 | 0.004588 |
import pyaf.Bench.TS_datasets as tsds
import tests.artificial.process_artificial_dataset as art
art.process_dataset(N = 1024 , FREQ = 'D', seed = 0, trendtype = "MovingMedian", cycle_length = 5, transform = "Difference", sigma = 0.0, exog_count = 20, ar_order = 0); | antoinecarme/pyaf | tests/artificial/transf_Difference/trend_MovingMedian/cycle_5/ar_/test_artificial_1024_Difference_MovingMedian_5__20.py | Python | bsd-3-clause | 269 | 0.085502 |
class ClassLoaderError(Exception):
def __init__(self, typen=None, data=""):
self.type = typen
self.data = data
message = u"\n{}: {}".format(typen, data) if typen else unicode(data)
super(ClassLoaderError, self).__init__(message)
class VerificationError(Exception):
def __init__(... | alexkasko/krakatau-java | krakatau-lib/src/main/resources/Lib/Krakatau/error.py | Python | gpl-3.0 | 429 | 0.002331 |
import unittest
class TestTeiTag(unittest.TestCase):
pass
class TestFmtTag(unittest.TestCase):
pass
class TestRendTag(unittest.TestCase):
pass
class TestDeleteMe(unittest.TestCase):
pass
class TestDontTouchMe(unittest.TestCase):
pass
class TestReplaceMeWText(unittest.TestCase):
pass
class... | thomasowenmclean/tei_transformer | tests/test_tags.py | Python | gpl-2.0 | 362 | 0.022099 |
"""
Defines task classes that can compile, link etc..
Task can depend upon one another.
These task are wrappers around the functions provided in the buildfunctions
module
"""
from .tasks import Task, TaskError, register_task
from ..utils.reporting import HtmlReportGenerator, DummyReportGenerator
from .. import api
fr... | windelbouwman/ppci-mirror | ppci/build/buildtasks.py | Python | bsd-2-clause | 7,591 | 0 |
#!/usr/bin/env python
#
# dutycycleviz.py
#
# Copyright (C) 2013, Andre Puschmann <andre.puschmann@tu-ilmenau.de>
#
# 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 Licens... | andrepuschmann/dutycycleviz | dutycycleviz.py | Python | gpl-3.0 | 5,638 | 0.013125 |
class Test(object):
def q(self):
c = 3
<selection>a = 1
b = 2
<caret></selection> | akosyakov/intellij-community | python/testData/mover/multiLineSelection_afterDown.py | Python | apache-2.0 | 95 | 0.063158 |
#
# Autogenerated by Thrift
#
# DO NOT EDIT
# @generated
#
import typing as _typing
import py3lite_module_root.apache.thrift.metadata.lite_types as _fbthrift_metadata
import folly.iobuf as _fbthrift_iobuf
from thrift.py3lite.client import (
AsyncClient as _fbthrift_py3lite_AsyncClient,
SyncClient as _fbthrif... | facebook/fbthrift | thrift/compiler/test/fixtures/namespace/gen-py3lite/my/namespacing/test/hsmodule/lite_clients.py | Python | apache-2.0 | 3,331 | 0.003903 |
from find_it import find_closest
from tm2secs2tm import time2secs, secs2time, format_time
def find_nearest_time(look_for, target_data):
what = time2secs(look_for)
where = [time2secs(t) for t in target_data]
res = find_closest(what, where)
return(secs2time(res))
row_data = {}
with open('PaceData.csv'... | clovemfeng/studydemo | python_code/chapter11/page422.py | Python | gpl-2.0 | 1,263 | 0.003959 |
# Disk resizing dialog
#
# Copyright (C) 2012-2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed... | AdamWill/anaconda | pyanaconda/ui/gui/spokes/lib/resize.py | Python | gpl-2.0 | 21,784 | 0.002158 |
##
# Copyright (c) 2009-2017 Apple Inc. All rights reserved.
#
# 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, mod... | macosforge/ccs-calendarserver | txdav/xml/rfc6578.py | Python | apache-2.0 | 4,056 | 0.001233 |
# (c) 2012, Daniel Hokka Zakrisson <daniel@hozac.com>
#
# 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 lat... | qvicksilver/ansible | lib/ansible/utils/plugins.py | Python | gpl-3.0 | 8,792 | 0.003071 |
資料 = [1, 2, 3, 4, 5]
'''
program: list1.py
'''
print(資料[:3])
print(資料[2:])
print(資料[1:2])
a = [3, 5, 7, 11, 13]
for x in a:
if x == 7:
print('list contains 7')
break
print(list(range(10)))
for 索引 in range(-5, 6, 2):
print(索引)
squares = [ x*x for x in range(0, 11) ]
print(squares)
a = [10, '... | 2014c2g5/2014cadp | wsgi/local_data/brython_programs/list1.py | Python | gpl-3.0 | 609 | 0.007678 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
import machina.models.fields
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations ... | reinbach/django-machina | machina/apps/forum_member/migrations/0001_initial.py | Python | bsd-3-clause | 1,410 | 0.004255 |
import numpy as np
from keras.layers import containers
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, MaxoutDense, Activation
from keras.optimizers import SGD, RMSprop, Adagrad, Adam
from keras.regularizers import l2
from keras.callbacks import EarlyStopping
# import matplotlib.pyp... | ml-slac/deep-jets | train.py | Python | mit | 2,806 | 0.010335 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Menu principal del sistema GEINED"""
import cgitb ; cgitb.enable()
import cgi
import htm
import subprocess
import pagina
def principal():
"""Menu principal"""
pag = pagina.Pagina("Menu principal", 10)
print(htm.h1("Menú principal"))
print(htm.table(
... | mescobal/geined | geined.py | Python | gpl-3.0 | 11,692 | 0.007216 |
from dolfin import *
from dolfin_adjoint import *
parameters["adjoint"]["cache_factorizations"] = True
mesh = UnitSquareMesh(3, 3)
V = FunctionSpace(mesh, "R", 0)
test = TestFunction(V)
trial = TrialFunction(V)
def main(m):
u = interpolate(Constant(0.1), V, name="Solution")
F = inner(u*u, test)*dx - inner(... | live-clones/dolfin-adjoint | tests_dolfin/hessian_identity_list/hessian_identity_list.py | Python | lgpl-3.0 | 1,279 | 0.003127 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
make-release
~~~~~~~~~~~~
Helper script that performs a release. Does pretty much everything
automatically for us.
:copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import sys
import os
import re
from dat... | Rafiot/logbook | scripts/make-release.py | Python | bsd-3-clause | 4,069 | 0.000983 |
#! /usr/bin/env python
from __future__ import print_function
from openturns import *
TESTPREAMBLE()
RandomGenerator.SetSeed(0)
try:
# Instanciate one distribution object
dimension = 3
meanPoint = NumericalPoint(dimension, 1.0)
meanPoint[0] = 0.5
meanPoint[1] = -0.5
sigma = NumericalPoint(dime... | dubourg/openturns | python/test/t_KernelMixture_std.py | Python | gpl-3.0 | 4,057 | 0.000986 |
from fabric.api import *
settings_fabric = settings
def identify(env):
if 'linux' in env.uname.lower():
with settings_fabric(warn_only=True):
env.lsb_release = env.lsb_release or run('lsb_release -d').lower()
if 'debian' in env.lsb_release:
return True
def settings(... | ryanwitt/django-liberace | liberace/systems/debian.py | Python | bsd-2-clause | 554 | 0.00722 |
import re
import lib.slack.config as config
import lib.slack.util as util
def nick_tracker(log_dict):
"""
Tracks all nicks and the identifies nicks which point to same user
Args:
log_dict(dictionary): with key as dateTime.date object and value as {"data":datalist,"channel_name":channels name... | prasadtalasila/IRCLogParser | lib/slack/nickTracker.py | Python | gpl-3.0 | 2,925 | 0.003419 |
<<<<<<< HEAD
<<<<<<< HEAD
# Test properties of bool promised by PEP 285
import unittest
from test import support
import os
class BoolTest(unittest.TestCase):
def test_subclass(self):
try:
class C(bool):
pass
except TypeError:
pass
else:
... | ArcherSys/ArcherSys | Lib/test/test_bool.py | Python | mit | 36,233 | 0.004554 |
# Time: O(n)
# Space: O(1)
# Given two integers n and k,
# you need to construct a list which contains n different positive integers
# ranging from 1 to n and obeys the following requirement:
# Suppose this list is [a1, a2, a3, ... , an],
# then the list [|a1 - a2|, |a2 - a3|, |a3 - a4|, ... , |an-1 - an|] has
# exac... | tudennis/LeetCode---kamyu104-11-24-2015 | Python/beautiful-arrangement-ii.py | Python | mit | 1,326 | 0 |
###############################################################################
#
# Tests for XlsxWriter.
#
# Copyright (c), 2013, John McNamara, jmcnamara@cpan.org
#
import unittest
import os
from ...workbook import Workbook
from ..helperfunctions import _compare_xlsx_files
class TestCompareXLSXFiles(unittest.TestC... | ivmech/iviny-scope | lib/xlsxwriter/test/comparison/test_chart_axis14.py | Python | gpl-3.0 | 2,805 | 0 |
'''
Created on Nov 2, 2012
@author: maodouzi
'''
import logging
from keystoneclient.v2_0 import client as keystone_client
from novaclient.v1_1 import client as nova_client
from cinderclient.v1 import client as cinder_client
from keystoneclient.exceptions import BadRequest
from openstack_dashboard.local.local_setting... | 99cloud/keystone_register | openstack_dashboard/register/register.py | Python | apache-2.0 | 6,455 | 0.007126 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Problem 100
If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2.
The next such arrangement, for w... | byung-u/ProjectEuler | Problem_100_199/euler_100.py | Python | mit | 1,335 | 0.004498 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""setup.py: setuptools control."""
import ez_setup
ez_setup.use_setuptools()
from os.path import dirname, abspath, join
from setuptools import setup
BASE_DIR = join(dirname(abspath(__file__)), 'orka/orka.py')
import orka
requires = ['kamaki','paramiko','requests','PyYA... | grnet/e-science | orka/setup.py | Python | agpl-3.0 | 676 | 0.028107 |
import os
import tempfile
import unittest
from nose.tools import raises
from nose.tools import timed
from ansible import errors
from ansible.module_common import ModuleReplacer
from ansible.utils import md5 as utils_md5
TEST_MODULE_DATA = """
from ansible.module_utils.basic import *
def get_module():
return Ans... | shirou/ansible | test/units/TestModuleUtilsBasic.py | Python | gpl-3.0 | 12,253 | 0.003101 |
# -*- coding: utf-8 -*
#
# Test links:
# https://www.androidfilehost.com/?fid=95916177934518197
import re
from module.plugins.internal.SimpleHoster import SimpleHoster
class AndroidfilehostCom(SimpleHoster):
__name__ = "AndroidfilehostCom"
__type__ = "hoster"
__version__ = "0.05"
__status__ ... | Guidobelix/pyload | module/plugins/hoster/AndroidfilehostCom.py | Python | gpl-3.0 | 2,454 | 0.014262 |
#
# Copyright (c) 2017 Red Hat
# Licensed under The MIT License (MIT)
# http://opensource.org/licenses/MIT
#
from rest_framework import serializers
from django.conf import settings as django_settings
import re
from datetime import datetime
import six
from pdc.apps.common.fields import ChoiceSlugField
from pdc.apps.co... | release-engineering/product-definition-center | pdc/apps/componentbranch/serializers.py | Python | mit | 11,180 | 0.000537 |
""" Load extensions. """
from os import listdir, path as op
CURDIR = op.dirname(__file__)
LINTERS = dict()
PREFIX = 'pylama_'
try:
from importlib import import_module
except ImportError:
from ..libs.importlib import import_module
for p in listdir(CURDIR):
if p.startswith(PREFIX) and op.isdir(op.join(CU... | ack8006/Python-mode-klen | pymode/libs/pylama/lint/extensions.py | Python | lgpl-3.0 | 738 | 0 |
#!/usr/bin/env python
import os.path
import sys
MODULE_ROOT = os.path.join(os.path.dirname(__file__), '..')
sys.path.insert(0, MODULE_ROOT)
from to_battle.player import Hero, Villain
from to_battle.battle import Battle
if __name__ == '__main__':
player1 = Hero(name='Rico')
player2 = Villain(name='Thanos')
... | ricomoss/python-april-2014 | class7/to_battle/script.py | Python | mit | 380 | 0.005263 |
""" Bootstrap the mauzr agent on cpython systems. """
import contextlib
import threading
import logging
import _thread
__author__ = "Alexander Sowitzki"
class Core:
""" Manage program components on cpython platforms.
The core can either be started directly by calling :func:`run` or
by using it as a con... | eqrx/mauzr | mauzr/platform/cpython/__init__.py | Python | agpl-3.0 | 5,160 | 0 |
"""
===============================
OCR Letter sequence recognition
===============================
This example illustrates the use of a chain CRF for optical character
recognition. The example is taken from Taskar et al "Max-margin markov random
fields".
Each example consists of a handwritten word, that was presegme... | d-mittal/pystruct | examples/plot_letters.py | Python | bsd-2-clause | 3,493 | 0 |
"""
======================================
Decision Tree Regression with AdaBoost
======================================
A decision tree is boosted using the AdaBoost.R2 [1] algorithm on a 1D
sinusoidal dataset with a small amount of Gaussian noise.
299 boosts (300 decision trees) is compared with a single decision tr... | DailyActie/Surrogate-Model | 01-codes/scikit-learn-master/examples/ensemble/plot_adaboost_regression.py | Python | mit | 1,530 | 0.002614 |
import unittest
from distributed_queue.serializers import BaseSerializer, JsonSerializer
class TestSerializers(unittest.TestCase):
def test_base_serializer(self):
self.assertRaises(NotImplementedError, BaseSerializer.dumps, {})
self.assertRaises(NotImplementedError, BaseSerializer.loads, "{}"... | ProstoKSI/distributed-queue | distributed_queue/tests/test_serializers.py | Python | mit | 556 | 0.005396 |
import hou
from PySide2.QtCore import Slot, QSortFilterProxyModel, QRegExp, Qt
from PySide2.QtWidgets import QInputDialog, QMessageBox
from . import hpaste
from .hcollections.collectionwidget import CollectionWidget
from .hcollections.collectionbase import CollectionSyncError, CollectionItem
from .hcollections.github... | pedohorse/hpaste | python3.7libs/hpaste/hpastecollectionwidget.py | Python | lgpl-3.0 | 12,806 | 0.003904 |
import os
from assertions import assert_crc_check_chance_equal
from scrub_test import TestHelper
from tools import since
class TestCompression(TestHelper):
def _get_compression_type(self, file):
types = {
'0010': 'NONE',
'789c': 'DEFLATE'
}
with open(file, 'rb') ... | thobbs/cassandra-dtest | compression_test.py | Python | apache-2.0 | 7,536 | 0.003583 |
# coding: utf-8
# Examples for NOT class
# In[1]:
# imports
from __future__ import print_function
from BinPy.Gates import *
# In[2]:
# Initializing the NOT class
gate = NOT(0)
# Output of the NOT gate
print (gate.output())
# In[3]:
# Input is changed to 0
gate.setInput(1)
# To get the input states
print... | MridulS/BinPy | BinPy/examples/source/Gates/NOT.py | Python | bsd-3-clause | 731 | 0.00684 |
#!/usr/bin/env python
# File created on 10 Nov 2011
from __future__ import division
__author__ = "Jesse Stombaugh"
__copyright__ = "Copyright 2011, The QIIME project"
__credits__ = ["Jesse Stombaugh"]
__license__ = "GPL"
__version__ = "1.9.1-dev"
__maintainer__ = "Jesse Stombaugh"
__email__ = "jesse.stombaugh@colorado... | josenavas/qiime | scripts/clean_raxml_parsimony_tree.py | Python | gpl-2.0 | 3,356 | 0.001788 |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-18 13:28
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('climatemodels', '0046_auto_20170117_1034'),
]
operations = [
migrations.Alt... | bruecksen/isimip | isi_mip/climatemodels/migrations/0047_auto_20170118_1428.py | Python | mit | 45,674 | 0.003416 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.project")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| zephiro/django-boilerplate | {{cookiecutter.repo_name}}/{{cookiecutter.project_name}}/manage.py | Python | mit | 250 | 0 |
# prog6_7.py
# This program calculates total wages in a week given hours works and pay rate
# <Chad Hobbs>
def main(): # Main program
hrs = eval(input("How many hours have been worked this week?: "))
rate = eval(input("What is the pay rate for this employee?: "))
if hrs > 40:
wages = ... | itsallvoodoo/csci-school | CSCI220/Week 08 - MAR05-09/prog6_7.py | Python | apache-2.0 | 489 | 0.00409 |
"""
Definition of views.
"""
from django.shortcuts import render
from django.http import HttpRequest
from django.template import RequestContext
from datetime import datetime
def home(request):
"""Renders the home page."""
assert isinstance(request, HttpRequest)
return render(request,
'app/index.ht... | Kiddinglife/iamhungry | iamhungry/app/views.py | Python | lgpl-3.0 | 3,665 | 0.024557 |
import testify as T
from pushmanager.testing.testservlet import TemplateTestCase
class PushesTemplateTest(TemplateTestCase):
authenticated = True
pushes_page = 'pushes.html'
new_push_page = 'new-push.html'
def render_pushes_page(self, page_title='Pushes', pushes=[], pushes_per_page=50, last_push=No... | asottile/pushmanager | pushmanager/tests/test_template_pushes.py | Python | apache-2.0 | 835 | 0.007186 |
""" lintswitch lints your code in the background.
http://github.com/grahamking/lintswitch
"""
import sys
import socket
import logging
import os
import os.path
import argparse
from threading import Thread
try:
# python 3
from queue import Queue
except ImportError:
# python 2
from Queue import Queue
fro... | grahamking/lintswitch | lintswitch/main.py | Python | gpl-3.0 | 4,151 | 0 |
# -*- 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):
# Adding model 'Album'
db.create_table(u'photo_album', (
(u'i... | vadosl/photorganizer | photorganizer/photo/migrations/0001_initial.py | Python | mit | 8,572 | 0.007116 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This progra... | spbguru/repo1 | nupic/support/__init__.py | Python | gpl-3.0 | 27,136 | 0.011829 |
# -*- coding: utf-8 -*-
#
# This file is part of MyPaint.
# Copyright (C) 2007-2019 by the MyPaint Development Team.
# Copyright (C) 2007-2014 by Martin Renold <martinxyz@gmx.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published ... | mypaint/mypaint | gui/drawwindow.py | Python | gpl-2.0 | 34,612 | 0.000751 |
#!/usr/bin/env python2
# Copyright 2012 Neil Forrester
# Licensed under the Red Spider Project License.
# See the License.txt that shipped with your copy of this software for details.
import re
import argparse
import os
import sys
import codecs
xf = __import__('xkcd-fetch')
if __name__ == "__main__":
# set up comm... | the-xkcd-community/the-red-spider-project | src/xkcd-search.py | Python | mit | 1,201 | 0.029975 |
from django.conf.urls import patterns, include, url
from apps.pages import views
# See: https://docs.djangoproject.com/en/dev/topics/http/urls/
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
)
| 10printhello/Blank-Heroku-Django-App | backoffice/backoffice/apps/pages/urls.py | Python | gpl-2.0 | 217 | 0.009217 |
import gc
import hashlib
import os
import os.path
import tempfile
import zipfile
import numpy as np
import pytest
import requests
from hyperspy import signals
from hyperspy.io import load
MY_PATH = os.path.dirname(__file__)
ZIPF = os.path.join(MY_PATH, "edax_files.zip")
TMP_DIR = tempfile.TemporaryDirectory()
TEST_F... | thomasaarholt/hyperspy | hyperspy/tests/io/test_edax.py | Python | gpl-3.0 | 19,779 | 0.001466 |
"""Tests for Oscapcontent
:Requirement: Oscapcontent
:CaseAutomation: Automated
:CaseLevel: Acceptance
:CaseComponent: UI
:TestType: Functional
:CaseImportance: High
:Upstream: No
"""
import unittest2
from fauxfactory import gen_string
from nailgun import entities
from robottelo.config import settings
from robo... | elyezer/robottelo | tests/foreman/ui/test_oscapcontent.py | Python | gpl-3.0 | 6,070 | 0 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Import module for legacy KDE .po files.
This is an extension of standard gettext PO files.
You can read more about this file format from:
* http://l10n.kde.org/docs/translati... | abramhindle/UnnaturalCodeFork | python/testdata/launchpad/lib/lp/translations/utilities/kde_po_importer.py | Python | agpl-3.0 | 3,250 | 0.000308 |
# 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
# distributed under the Li... | pypa/warehouse | warehouse/migrations/versions/34b18e18775c_add_last_totp_value_to_user.py | Python | apache-2.0 | 940 | 0.001064 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.