repo_name stringlengths 5 100 | path stringlengths 4 375 | copies stringclasses 991
values | size stringlengths 4 7 | content stringlengths 666 1M | license stringclasses 15
values |
|---|---|---|---|---|---|
pfalcon/ScratchABlock | correct_internal_entrypoint.py | 1 | 1344 | #!/usr/bin/env python3
import sys
import os
import glob
def process_file(fname):
func_name = None
with open(fname) as f:
l = f.readline()
if not l.startswith("; Entry point: "):
return
l = l.strip()
head, func_name = l.rsplit(None, 1)
assert func_name
prin... | gpl-3.0 |
likaiwalkman/phantomjs | src/qt/qtwebkit/Tools/Scripts/webkitpy/w3c/test_parser.py | 135 | 6756 | #!/usr/bin/env python
# Copyright (C) 2013 Adobe Systems Incorporated. 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 n... | bsd-3-clause |
zeptonaut/catapult | dashboard/dashboard/edit_site_config_test.py | 4 | 4132 | # 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 unittest
import webapp2
import webtest
from google.appengine.api import users
from dashboard import edit_site_config
from dashboard import namespac... | bsd-3-clause |
Debian/openjfx | modules/web/src/main/native/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py | 3 | 11619 | #!/usr/bin/env python
#
# Copyright (c) 2014-2016 Apple Inc. All rights reserved.
# Copyright (c) 2014 University of Washington. 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. Redistribution... | gpl-2.0 |
ashray/VTK-EVM | ThirdParty/Twisted/twisted/words/protocols/jabber/jid.py | 68 | 7157 | # -*- test-case-name: twisted.words.test.test_jabberjid -*-
#
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Jabber Identifier support.
This module provides an object to represent Jabber Identifiers (JIDs) and
parse string representations into them with proper checking for illegal
charact... | bsd-3-clause |
mikedchavez1010/XX-Net | gae_proxy/server/lib/google/appengine/api/conf.py | 6 | 11768 | #!/usr/bin/env python
#
# Copyright 2007 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 o... | bsd-2-clause |
timorieber/wagtail | wagtail/contrib/modeladmin/templatetags/modeladmin_tags.py | 5 | 6591 | import datetime
from django.contrib.admin.templatetags.admin_list import ResultList, result_headers
from django.contrib.admin.utils import display_for_field, display_for_value, lookup_field
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.forms.utils import flatatt
from dj... | bsd-3-clause |
cyankw/keyboard_recorder | Beta Testing Version/py-hook V2.py | 2 | 1695 | # -*- coding: utf-8 -*- #
__author__ = 'cyankw'
import pythoncom
import pyHook
import datetime
import urllib, base64
from multiprocessing import Pool
kll=[]
kll2=[]
oldname = ''
def onKeyboardEvent(event):
# 监听键盘事件
timeNow = datetime.datetime.now()
Now = timeNow.strftime('%H:%M:%S')
wrfile = open(r'd... | apache-2.0 |
ryangibbs/tosser | three.js/utils/exporters/blender/addons/io_three/exporter/api/mesh.py | 124 | 23228 | """
Blender API for querying mesh data. Animation data is also
handled here since Three.js associates the animation (skeletal,
morph targets) with the geometry nodes.
"""
import operator
from bpy import data, types, context
from . import material, texture, animation
from . import object as object_
from .. import const... | mit |
chenjun0210/tensorflow | tensorflow/python/framework/subscribe.py | 16 | 11056 | # Copyright 2016 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... | apache-2.0 |
gibxxi/nzbToMedia | libs/jaraco/windows/api/credential.py | 4 | 1290 | """
Support for Credential Vault
"""
import ctypes
from ctypes.wintypes import DWORD, LPCWSTR, BOOL, LPWSTR, FILETIME
try:
from ctypes.wintypes import LPBYTE
except ImportError:
LPBYTE = ctypes.POINTER(ctypes.wintypes.BYTE)
class CredentialAttribute(ctypes.Structure):
_fields_ = []
class Credential(ctypes.Struct... | gpl-3.0 |
smartdata-x/robots | pylib/Twisted/twisted/words/topfiles/setup.py | 22 | 1965 | # Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
try:
from twisted.python import dist
except ImportError:
raise SystemExit("twisted.python.dist module not found. Make sure you "
"have installed the Twisted core package before "
"attempting to in... | apache-2.0 |
recsm/SQP | sqp/migrations/0062_adding_userprofile_activation_key.py | 1 | 24092 | # encoding: 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 'UserProfile.activation_key'
db.add_column('sqp_userprofile', 'activation_key', self.gf('dj... | mit |
sid-kap/pants | src/python/pants/backend/jvm/ivy_utils.py | 4 | 19614 | # 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)
import errno
import ... | apache-2.0 |
cneill/designate-testing | designate/storage/impl_sqlalchemy/migrate_repo/versions/058_placeholder.py | 140 | 1035 | # Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# Author: Kiall Mac Innes <kiall@hp.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/L... | apache-2.0 |
lawrence34/python-social-auth | social/strategies/webpy_strategy.py | 77 | 1932 | import web
from social.strategies.base import BaseStrategy, BaseTemplateStrategy
class WebpyTemplateStrategy(BaseTemplateStrategy):
def render_template(self, tpl, context):
return web.template.render(tpl)(**context)
def render_string(self, html, context):
return web.template.Template(html)(*... | bsd-3-clause |
jhawkesworth/ansible | lib/ansible/modules/windows/win_command.py | 40 | 3974 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2016, Ansible, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'core'}
DOCUMENTATIO... | gpl-3.0 |
maohongyuan/kbengine | kbe/src/lib/python/Lib/idlelib/idle_test/test_textview.py | 79 | 2871 | '''Test the functions and main class method of textView.py.
Since all methods and functions create (or destroy) a TextViewer, which
is a widget containing multiple widgets, all tests must be gui tests.
Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
The coverage is es... | lgpl-3.0 |
ardi69/pyload-0.4.10 | lib/Python/Lib/Crypto/Cipher/PKCS1_v1_5.py | 123 | 9103 | # -*- coding: utf-8 -*-
#
# Cipher/PKCS1-v1_5.py : PKCS#1 v1.5
#
# ===================================================================
# The contents of this file are dedicated to the public domain. To
# the extent that dedication to the public domain is not available,
# everyone is granted a worldwide, perpetual, ro... | gpl-3.0 |
kemalakyol48/python-for-android | python-build/python-libs/gdata/src/gdata/tlslite/utils/codec.py | 361 | 2771 | """Classes for reading/writing binary data (such as TLS records)."""
from compat import *
class Writer:
def __init__(self, length=0):
#If length is zero, then this is just a "trial run" to determine length
self.index = 0
self.bytes = createByteArrayZeros(length)
def add(self, x, lengt... | apache-2.0 |
gangadhar-kadam/helpdesk-frappe | frappe/desk/query_report.py | 7 | 8955 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
import os, json
from frappe import _
from frappe.modules import scrub, get_module_path
from frappe.utils import flt, cint, get_html_format
from frappe.translate im... | mit |
mainecivichackday/wheresyourtrash | wheresyourtrash/apps/email2sms/models.py | 2 | 1080 | from django.core.urlresolvers import reverse
from django.db.models import *
from django_extensions.db.fields import AutoSlugField
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth import models as auth_models
from django.... | bsd-3-clause |
drpeteb/scipy | scipy/io/matlab/tests/test_mio5_utils.py | 106 | 5604 | """ Testing mio5_utils Cython module
"""
from __future__ import division, print_function, absolute_import
import sys
from io import BytesIO
cStringIO = BytesIO
import numpy as np
from nose.tools import (assert_true, assert_equal, assert_raises)
from numpy.testing import (assert_array_equal, run_module_suite)
fro... | bsd-3-clause |
elopio/snapcraft | tests/unit/test_meta.py | 1 | 39249 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2015-2018 Canonical Ltd
#
# 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 ... | gpl-3.0 |
numerigraphe/odoo | addons/account_analytic_default/account_analytic_default.py | 256 | 8118 | # -*- coding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GN... | agpl-3.0 |
amozie/amozie | studzie/scrapy_tutor/hello/hello/settings.py | 1 | 3118 | # -*- coding: utf-8 -*-
# Scrapy settings for hello project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
# http://scrapy.readthedocs.org/en/latest/t... | apache-2.0 |
meejah/AutobahnPython | autobahn/wamp/protocol.py | 1 | 61912 | ###############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) Tavendo GmbH
#
# 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 with... | mit |
franosincic/edx-platform | common/test/acceptance/tests/studio/test_studio_settings.py | 13 | 19722 | # coding: utf-8
"""
Acceptance tests for Studio's Setting pages
"""
from __future__ import unicode_literals
from nose.plugins.attrib import attr
from base_studio_test import StudioCourseTest
from bok_choy.promise import EmptyPromise
from ...fixtures.course import XBlockFixtureDesc
from ..helpers import create_user_par... | agpl-3.0 |
hseifeddine/dashviz-mean | node_modules/node-gyp/gyp/tools/pretty_gyp.py | 2618 | 4756 | #!/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.
"""Pretty-prints the contents of a GYP file."""
import sys
import re
# Regex to remove comments when we're counting braces.
COMMENT_RE = ... | mit |
101companies/101dev | tools/wikiRefactoring/refactor.py | 4 | 1406 | import sys
import getpass
from wikitools import wiki
import page2
import category2
apiurl = "http://mediawiki.101companies.org/api.php"
wiki101 = wiki.Wiki(apiurl)
def dorename(titles, flags):
if len(titles) < 2:
exit("Need two titles to do renaming")
if titles[0].startswith("Category:"):
p = category2.Category... | gpl-3.0 |
sestrella/ansible | lib/ansible/modules/utilities/logic/import_role.py | 28 | 2837 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['... | gpl-3.0 |
phihag/youtube-dl | youtube_dl/extractor/echomsk.py | 90 | 1317 | # coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
class EchoMskIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?echo\.msk\.ru/sounds/(?P<id>\d+)'
_TEST = {
'url': 'http://www.echo.msk.ru/sounds/1464134.html',
'md5': '2e44b3b78daff5b458e4d... | unlicense |
xbmc/xbmc-antiquated | xbmc/lib/libPython/Python/Lib/test/test_strptime.py | 12 | 23211 | """PyUnit testing against strptime"""
import unittest
import time
import locale
import re
import sys
from test import test_support
from datetime import date as datetime_date
import _strptime
class getlang_Tests(unittest.TestCase):
"""Test _getlang"""
def test_basic(self):
self.failUnlessEqual(_strpti... | gpl-2.0 |
geopm/geopm | scripts/test/TestAgent.py | 1 | 2853 | #!/usr/bin/env python3
#
# Copyright (c) 2015 - 2021, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, th... | bsd-3-clause |
cjcjameson/gpdb | gpMgmt/sbin/gpsegstop.py | 24 | 8204 | #!/usr/bin/env python
#
# Copyright (c) Greenplum Inc 2008. All Rights Reserved.
#
#
# Internal Use Function.
#
#
#
# THIS IMPORT MUST COME FIRST
#
# import mainUtils FIRST to get python version check
from gppylib.mainUtils import *
import os, sys, time, signal
from optparse import Option, OptionGroup, OptionParser, ... | apache-2.0 |
castelao/oceansdb | setup.py | 1 | 1497 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from setuptools import setup
from codecs import open
with open('README.rst', encoding='utf-8') as f:
readme = f.read()
with open('HISTORY.rst', encoding='utf-8') as f:
history = f.read().replace('..... | bsd-3-clause |
mark-burnett/filament-dynamics | actin_dynamics/numerical/old_correlation.py | 1 | 5017 | # Copyright (C) 2011 Mark Burnett
#
# 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 program i... | gpl-3.0 |
ytjiang/django | tests/extra_regress/tests.py | 207 | 15018 | from __future__ import unicode_literals
import datetime
from collections import OrderedDict
from django.contrib.auth.models import User
from django.test import TestCase
from .models import Order, RevisionableModel, TestObject
class ExtraRegressTests(TestCase):
def setUp(self):
self.u = User.objects.cr... | bsd-3-clause |
bitpew/vagrant-graphite-apache2 | provisioning/etc/graphite/local_settings.py | 2 | 8300 | ## Graphite local_settings.py
# Edit this file to customize the default Graphite webapp settings
#
# Additional customizations to Django settings can be added to this file as well
#####################################
# General Configuration #
#####################################
# Set this to a long, random unique s... | apache-2.0 |
darjus-amzn/boto | tests/integration/storage_uri/test_storage_uri.py | 132 | 2355 | # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
# 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 ... | mit |
f5devcentral/f5-cccl | f5_cccl/resource/ltm/test/test_virtual.py | 1 | 13147 | #!/usr/bin/env python
# Copyright (c) 2017-2021 F5 Networks, 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 appl... | apache-2.0 |
Learningtribes/edx-platform | lms/djangoapps/instructor_task/tasks_helper.py | 6 | 74119 | """
This file contains tasks that are designed to perform background operations on the
running state of a course.
"""
import json
import re
from collections import OrderedDict
from datetime import datetime
from django.conf import settings
from eventtracking import tracker
from itertools import chain
from time import t... | agpl-3.0 |
andrewshadura/omim | tools/python/google_translate.py | 53 | 1336 | #!/usr/bin/python
import re
import sys
import urllib
import simplejson
import time
baseUrl = "http://www.googleapis.com/language/translate/v2"
def translate(text,src='en'):
targetLangs = ["ja", "fr", "ar", "de", "ru", "sv", "zh", "fi", "ko", "ka", "be", "nl", "ga", "el", "it", "es", "th", "ca", "cy", "hu", "sr... | apache-2.0 |
songmonit/CTTMSONLINE | addons/email_template/__init__.py | 381 | 1144 | # -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2009 Sharoon Thomas
# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it ... | agpl-3.0 |
rc/sfepy | sfepy/solvers/optimize.py | 4 | 13138 | from __future__ import absolute_import
import numpy as nm
import numpy.linalg as nla
from sfepy.base.base import output, get_default, pause, Struct
from sfepy.base.log import Log, get_logging_conf
from sfepy.base.timing import Timer
from sfepy.solvers.solvers import OptimizationSolver
import scipy.optimize as sopt
i... | bsd-3-clause |
frankvdp/django | django/db/backends/base/base.py | 10 | 24014 | import copy
import time
import warnings
from collections import deque
from contextlib import contextmanager
import _thread
import pytz
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import DEFAULT_DB_ALIAS
from django.db.backends import utils
from django.db.bac... | bsd-3-clause |
nthiep/global-ssh-server | lib/python2.7/site-packages/django/contrib/auth/tests/remote_user.py | 9 | 8779 | from datetime import datetime
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth.backends import RemoteUserBackend
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.test import TestCase... | agpl-3.0 |
mtekel/libcloud | libcloud/compute/drivers/softlayer.py | 22 | 16262 | # 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 ... | apache-2.0 |
Gravecorp/Gap | packages/IronPython.StdLib.2.7.3/content/Lib/netrc.py | 168 | 4576 | """An object-oriented interface to .netrc files."""
# Module and documentation by Eric S. Raymond, 21 Dec 1998
import os, shlex
__all__ = ["netrc", "NetrcParseError"]
class NetrcParseError(Exception):
"""Exception raised on syntax errors in the .netrc file."""
def __init__(self, msg, filename=None, lineno=... | mpl-2.0 |
adaussy/eclipse-monkey-revival | plugins/python/org.eclipse.eclipsemonkey.lang.python/Lib/test/test_hmac.py | 4 | 13149 | import hmac
import hashlib
import unittest
import warnings
from test import test_support
class TestVectorsTestCase(unittest.TestCase):
def test_md5_vectors(self):
# Test the HMAC module against test vectors from the RFC.
def md5test(key, data, digest):
h = hmac.HMAC(key, data)
... | epl-1.0 |
gioman/QGIS | tests/src/python/test_qgsgraduatedsymbolrenderer.py | 1 | 17127 | # -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsGraduatedSymbolRenderer
.. note:: 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 2 of the License, or
(at your option) any later vers... | gpl-2.0 |
jjmiranda/edx-platform | common/lib/xmodule/xmodule/contentstore/utils.py | 235 | 1470 | from xmodule.contentstore.content import StaticContent
from .django import contentstore
def empty_asset_trashcan(course_locs):
'''
This method will hard delete all assets (optionally within a course_id) from the trashcan
'''
store = contentstore('trashcan')
for course_loc in course_locs:
... | agpl-3.0 |
jacky-young/crosswalk-test-suite | stability/stability-iterative-android-tests/iterative/Install_Uninstall_Repeatedly.py | 2 | 3521 | #!/usr/bin/env python
#coding=utf-8
#
# Copyright (c) 2015 Intel Corporation.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of works must retain the original copyright notice, this
# list of co... | bsd-3-clause |
sunyihuan326/DeltaLab | Andrew_NG_learning/class_four/week_four/FR/fr_utils.py | 1 | 8668 | #### PART OF THIS CODE IS USING CODE FROM VICTOR SY WANG: https://github.com/iwantooxxoox/Keras-OpenFace/blob/master/utils.py ####
import tensorflow as tf
import numpy as np
import os
# import cv2
from numpy import genfromtxt
from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate
from keras.mod... | mit |
ashemedai/ansible | lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py | 26 | 7566 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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
#... | gpl-3.0 |
XristosMallios/cache | exareme-tools/madis/src/functions/vtable/sdc2db.py | 4 | 6517 | import os.path
import sys
import functions
import os
from itertools import repeat, imap
import cPickle
import cStringIO
import vtbase
import functions
import struct
import vtbase
import os
import re
import zlib
import apsw
from array import array
import marshal
if hasattr(sys, 'pypy_version_info'):
from __pypy__ ... | mit |
AmrnotAmr/zato | code/zato-web-admin/src/zato/admin/web/views/security/tls/channel.py | 6 | 1845 | # -*- coding: utf-8 -*-
"""
Copyright (C) 2014 Dariusz Suchojad <dsuch at zato.io>
Licensed under LGPLv3, see LICENSE.txt for terms and conditions.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
# stdlib
import logging
# Zato
from zato.admin.web.forms.security.tls.channel im... | gpl-3.0 |
mhoffma/micropython | tests/basics/with_return.py | 82 | 1239 | class CtxMgr:
def __init__(self, id):
self.id = id
def __enter__(self):
print("__enter__", self.id)
return self
def __exit__(self, a, b, c):
print("__exit__", self.id, repr(a), repr(b))
# simple case
def foo():
with CtxMgr(1):
return 4
print(foo())
# for loop ... | mit |
Eslamunto/Gestern-HIG | django/book-1/djangobook-1.py | 1 | 13193 | MODULE ONE!
Chapter One:
Django's Position on the Web'
NOTE: Text in here needs to be paraphrased as it was taken as copy-paste from the book directly.
Django's slogan
The web framework for perfectionists with deadlines.
MVC:
Models: These represent data organization in a database. In simple words,
we can say th... | mit |
barraponto/scrapy | tests/test_logformatter.py | 80 | 2131 | import unittest
import six
from scrapy.spiders import Spider
from scrapy.http import Request, Response
from scrapy.item import Item, Field
from scrapy.logformatter import LogFormatter
class CustomItem(Item):
name = Field()
def __str__(self):
return "name: %s" % self['name']
class LoggingContribTe... | bsd-3-clause |
patrickglass/creo | creo/packages/colorama/ansitowin32.py | 442 | 9262 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import re
import sys
import os
from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style
from .winterm import WinTerm, WinColor, WinStyle
from .win32 import windll
winterm = None
if windll is not None:
winterm = WinTerm()
def is_a_tty(stre... | apache-2.0 |
Andr3as/CodiadDirect | SublimeText2/requests/adapters.py | 6 | 15239 | # -*- coding: utf-8 -*-
"""
requests.adapters
~~~~~~~~~~~~~~~~~
This module contains the transport adapters that Requests uses to define
and maintain connections.
"""
import socket
from .models import Response
from .packages.urllib3 import Retry
from .packages.urllib3.poolmanager import PoolManager, proxy_from_url
... | mit |
cvsuser-chromium/chromium | native_client_sdk/src/build_tools/sdk_tools/command/info.py | 160 | 1162 | # Copyright (c) 2012 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 command_common
import logging
import manifest_util
def Info(manifest, bundle_names):
valid_bundles, invalid_bundles = command_common.GetValidBu... | bsd-3-clause |
ZazieTheBeast/oscar | src/oscar/apps/dashboard/orders/views.py | 15 | 33150 | import datetime
from collections import OrderedDict
from decimal import Decimal as D
from decimal import InvalidOperation
from django.conf import settings
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db.models import ... | bsd-3-clause |
ted-gould/nova | nova/api/openstack/compute/aggregates.py | 13 | 8862 | # Copyright (c) 2012 Citrix Systems, 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 ... | apache-2.0 |
2014c2g7/c2g7 | w2/static/Brython2.0.0-20140209-164925/Lib/unittest/main.py | 739 | 10385 | """Unittest main program"""
import sys
import optparse
import os
from . import loader, runner
from .signals import installHandler
__unittest = True
FAILFAST = " -f, --failfast Stop on first failure\n"
CATCHBREAK = " -c, --catch Catch control-C and display results\n"
BUFFEROUTPUT = " -b, --buffer ... | gpl-2.0 |
abtreece/ansible | lib/ansible/utils/module_docs_fragments/backup.py | 427 | 1071 | # Copyright (c) 2015 Ansible, Inc
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansi... | mit |
aonotas/chainer | chainer/functions/normalization/batch_renormalization.py | 1 | 8651 | import numpy
from chainer.backends import cuda
from chainer import configuration
from chainer import function
from chainer.utils import type_check
def _as4darray(arr):
if arr.ndim == 0:
return arr.reshape(1, 1, 1, 1)
elif arr.ndim == 4:
return arr
else:
return arr.reshape(arr.shap... | mit |
doganov/edx-platform | cms/djangoapps/contentstore/views/public.py | 47 | 2383 | """
Public views
"""
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.clickjacking import xframe_options_deny
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.conf import settings
from ... | agpl-3.0 |
m3dev/pptx-template | .eggs/python_pptx-0.6.6-py2.7.egg/pptx/chart/xmlwriter.py | 2 | 67454 | # encoding: utf-8
"""
Composers for default chart XML for various chart types.
"""
from __future__ import absolute_import, print_function, unicode_literals
from copy import deepcopy
from xml.sax.saxutils import escape
from ..compat import to_unicode
from ..enum.chart import XL_CHART_TYPE
from ..oxml import parse_xm... | apache-2.0 |
towerjoo/DjangoNotes | Django-1.5.1/django/conf/locale/nb/formats.py | 107 | 1585 | # -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'j. F Y'
TIME_FORMAT = 'H:i'
DATET... | mit |
kokke/tiny-bignum-c | scripts/test_rand.py | 1 | 4619 |
#
#
# Can take one command-line parameter: number of tests to run
#
# Runs NTESTS random tests of selecting an operand from + - *
# and applying it on two random operands and comparing the result
# to the one Python can calculate
#
# In effect, this verifies the C implementation against Python's
#
#
from random impo... | unlicense |
gq213/linux-3.10.72 | tools/perf/scripts/python/failed-syscalls-by-pid.py | 11180 | 2058 | # failed system call counts, by pid
# (c) 2010, Tom Zanussi <tzanussi@gmail.com>
# Licensed under the terms of the GNU GPL License version 2
#
# Displays system-wide failed system call totals, broken down by pid.
# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
import os
import sys
sys.pa... | gpl-2.0 |
devdelay/home-assistant | homeassistant/components/arduino.py | 7 | 3724 | """
Support for Arduino boards running with the Firmata firmware.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/arduino/
"""
import logging
from homeassistant.const import (
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP)
from homeassistant.h... | mit |
partofthething/home-assistant | tests/components/zha/test_device_tracker.py | 21 | 3026 | """Test ZHA Device Tracker."""
from datetime import timedelta
import time
import pytest
import zigpy.zcl.clusters.general as general
from homeassistant.components.device_tracker import DOMAIN, SOURCE_TYPE_ROUTER
from homeassistant.components.zha.core.registries import (
SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE,
)
f... | mit |
rionbr/CANA | cana/control/mds.py | 1 | 1888 | # -*- coding: utf-8 -*-
"""
Minimum Dominating Set
=======================
"""
# Copyright (C) 2021 by
# Alex Gates <ajgates42@gmail.com>
# Rion Brattig Correia <rionbr@gmail.com>
# All rights reserved.
# MIT license.
import itertools
#
# Minimum Dominating Set
#
def mds(directed_graph, max_search=5, keep... | mit |
takeshineshiro/heat | heat/objects/software_deployment.py | 5 | 3374 | # Copyright 2014 Intel Corp.
#
# 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, soft... | apache-2.0 |
eort/OpenSesame | libqtopensesame/runners/__init__.py | 2 | 1045 | #-*- coding:utf-8 -*-
"""
This file is part of OpenSesame.
OpenSesame 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.
OpenSesame is distri... | gpl-3.0 |
Event38/MissionPlanner | Lib/sre_constants.py | 64 | 7398 | #
# Secret Labs' Regular Expression Engine
#
# various symbols used by the regular expression engine.
# run this script to update the _sre include files!
#
# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
#
# See the sre.py file for information on usage and redistribution.
#
"""Internal su... | gpl-3.0 |
DailyActie/Surrogate-Model | 01-codes/scipy-master/scipy/linalg/blas.py | 1 | 6822 | """
Low-level BLAS functions (:mod:`scipy.linalg.blas`)
===================================================
This module contains low-level functions from the BLAS library.
.. versionadded:: 0.12.0
.. warning::
These functions do little to no error checking.
It is possible to cause crashes by mis-using them,
... | mit |
jetty840/ReplicatorG | skein_engines/skeinforge-50/fabmetheus_utilities/geometry/geometry_tools/vertex.py | 13 | 1524 | """
Vertex of a triangle mesh.
"""
from __future__ import absolute_import
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
from fabmetheus_utilities.geometry.geometry_utilities import evaluate... | gpl-2.0 |
cihai/cihai-python | cihai/data/unihan/bootstrap.py | 1 | 2283 | # -*- coding: utf8 - *-
from __future__ import absolute_import, print_function, unicode_literals
from sqlalchemy import Column, String, Table
from unihan_etl import process as unihan
from unihan_etl.process import UNIHAN_MANIFEST
from ...utils import merge_dict
from .constants import UNIHAN_ETL_DEFAULT_OPTIONS, UNIH... | bsd-3-clause |
Ceciliae/gourmet | gourmet/OptionParser.py | 6 | 2260 | import argparse
import version
try:
import argcomplete
has_argcomplete = True
except ImportError:
has_argcomplete = False
parser = argparse.ArgumentParser(prog='gourmet',description=version.description)
parser.add_argument('--version',action='version',version=version.version)
parser.add_argument('--databas... | gpl-2.0 |
vipulkanade/EventbriteDjango | lib/python2.7/encodings/koi8_r.py | 593 | 14035 | """ Python Character Mapping Codec koi8_r generated from 'MAPPINGS/VENDORS/MISC/KOI8-R.TXT' with gencodec.py.
"""#"
import codecs
### Codec APIs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
return codecs.charmap_encode(input,errors,encoding_table)
def decode(self,input,errors... | mit |
MuckRock/muckrock | muckrock/accounts/migrations/0033_auto_20171103_1713.py | 1 | 1051 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-11-03 17:13
import django.core.files.storage
from django.db import migrations, models
import easy_thumbnails.fields
class Migration(migrations.Migration):
dependencies = [
('accounts', '0032_auto_20171025_1551'),
]
operations = [
... | agpl-3.0 |
40123254/cdw11-ag3 | static/local_publishconf.py | 31 | 1680 | #!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
# This file is only used if you use `make publish` or
# explicitly specify it as your config file.
import os
import sys
sys.path.append(os.curdir)
from pelicanconf import *
# 因為 publishconf.py 在 pelicanconf.py 之後, 因此若兩處有相同變數的設定, ... | agpl-3.0 |
ewdurbin/sentry | src/sentry/models/organizationaccessrequest.py | 24 | 2510 | """
sentry.models.organizationmember
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import, print_function
import logging
from django.core.urlresolvers import reverse
from s... | bsd-3-clause |
pfdamasceno/shakespeare | content_sources/doi2bib.py | 1 | 1834 | #modified from https://gist.github.com/zmwangx
#!/usr/bin/env python
# Take one argument--the doi, and convert it to bibtex using an API
# call to dx.doi.org.
from sys import argv
import os, re
#if argv[0].find('doi') != -1:
# # run as executable
# doi = argv[1]
#else:
# # run from python
# doi = argv... | mit |
citueda/pimouse_run_corridor | test/travis_test_wall_trace.py | 1 | 1423 | #!/usr/bin/env python
import unittest, rostest
import rosnode, rospy
import time
class WallTraceTest(unittest.TestCase):
def set_and_get(self,lf,ls,rs,rf):
with open("/dev/rtlightsensor0","w") as f:
f.write("%d %d %d %d\n" % (rf,rs,ls,lf))
time.sleep(0.3)
with open("/dev/rtmot... | mit |
kimjaejoong/nova | nova/api/openstack/compute/schemas/v3/server_groups.py | 65 | 1564 | # Copyright 2014 NEC Corporation. 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 ... | apache-2.0 |
OCA/e-commerce | website_sale_attribute_filter_category/controllers/main.py | 2 | 1312 | # Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo import _, http
class ProductAttributeCategory(WebsiteSale):
@http.route()
def shop(self, page=0, category=None, search='', pp... | agpl-3.0 |
TakashiSasaki/ns-3-nat | src/uan/bindings/modulegen__gcc_LP64.py | 24 | 494820 | from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
import pybindgen.settings
import warnings
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, wrapper, exception, traceback_):
warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
... | gpl-2.0 |
inspirehep/invenio | modules/websubmit/lib/wsm_pdftk_plugin.py | 35 | 7328 | ## This file is part of Invenio.
## Copyright (C) 2010, 2011 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
... | gpl-2.0 |
dan1/horizon-proto | openstack_dashboard/contrib/sahara/content/data_processing/utils/workflow_helpers.py | 30 | 10029 | # 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... | apache-2.0 |
kingsamchen/Eureka | crack-data-structures-and-algorithms/leetcode/find_minimum_in_rotated_sorted_array_II_q154.py | 1 | 1154 | # -*- coding: utf-8 -*-
# 0xCCCCCCCC
# Like Q153 but with possible duplicates.
def find_min(nums):
"""
:type nums: List[int]
:rtype: int
"""
l, r = 0, len(nums) - 1
while l < r and nums[l] >= nums[r]:
m = (l + r) // 2
if nums[m] > nums[r]:
l = m + 1
elif num... | mit |
delta2323/chainer | examples/dcgan/net.py | 5 | 3623 | #!/usr/bin/env python
from __future__ import print_function
import numpy
import chainer
from chainer import cuda
import chainer.functions as F
import chainer.links as L
def add_noise(h, sigma=0.2):
xp = cuda.get_array_module(h.data)
if chainer.config.train:
return h + sigma * xp.random.randn(*h.sha... | mit |
rossgoodwin/musapaedia | musapaedia/muse/lib/python2.7/site-packages/setuptools/dist.py | 16 | 35330 | __all__ = ['Distribution']
import re
import os
import sys
import warnings
import numbers
import distutils.log
import distutils.core
import distutils.cmd
import distutils.dist
from distutils.core import Distribution as _Distribution
from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
Distuti... | mit |
surajssd/kuma | vendor/packages/translate/tools/phppo2pypo.py | 25 | 3433 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2009 Mozilla Corporation, Zuza Software Foundation
#
# This file is part of translate.
#
# translate 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; ... | mpl-2.0 |
abdoosh00/edx-platform | common/lib/sandbox-packages/verifiers/draganddrop.py | 70 | 15072 | """ Grader of drag and drop input.
Client side behavior: user can drag and drop images from list on base image.
Then json returned from client is:
{
"draggable": [
{ "image1": "t1" },
{ "ant": "t2" },
{ "molecule": "t3" },
]
}
values are target names.
or:
{
"dra... | agpl-3.0 |
initNirvana/Easyphotos | env/lib/python3.4/site-packages/wtforms/meta.py | 114 | 3684 | from wtforms.utils import WebobInputWrapper
from wtforms import i18n
class DefaultMeta(object):
"""
This is the default Meta class which defines all the default values and
therefore also the 'API' of the class Meta interface.
"""
# -- Basic form primitives
def bind_field(self, form, unbound_... | mit |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.