code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
from __future__ import unicode_literals
from telesign.rest import RestClient
VOICE_RESOURCE = "/v1/voice"
VOICE_STATUS_RESOURCE = "/v1/voice/{reference_id}"
class VoiceClient(RestClient):
"""
TeleSign's Voice API allows you to easily send voice messages. You can send alerts, reminders, and notifications,
... | TeleSign/python_telesign | telesign/voice.py | Python | mit | 1,341 |
from itertools import groupby
from operator import itemgetter
try:
import simplejson
except:
from django.utils import simplejson
from django.contrib.admin.templatetags.adminmedia import admin_media_prefix
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.contentty... | AASHE/django-linkcheck | linkcheck/views.py | Python | bsd-3-clause | 5,233 |
from __future__ import division, print_function
import numpy as np
has_simpleaudio=True
try:
import simpleaudio
except:
print("Cannot find simpleaudio package. Not installed?")
print('Try:\n(sudo) pip install --upgrade simpleaudio')
has_simpleaudio=False
def soundof(notes, duration, volume=1):
... | marcomusy/piano-fingering | pianoplayer/wavegenerator.py | Python | mit | 2,452 |
# The MIT License (MIT)
#
# Copyright (c) 2010-2015 Carnegie Mellon University
#
# 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... | SafeSlingerProject/SafeSlinger-AppEngine | safeslinger-messenger/python/checkStatus.py | Python | mit | 4,271 |
import json
def writeLanguageStats(name, percentages, individual, weights,total):
with open('report.txt', 'w') as outfile:
outfile.write('Total bytes: ' + str(total))
outfile.write('\n\nOverall code usage for '+name+':\n')
outfile.write(json.dumps(percentages, indent=1))
outfile.writ... | vishalkuo/codeStats | utils/writer.py | Python | mit | 636 |
# coding=utf-8
# __author__='Administrator'
import urllib2
req = urllib2.Request('http://blog.csdn.net/cqcre')
try:
urllib2.urlopen(req)
except urllib2.URLError, e:
if hasattr(e, "reason"):
print e.reason
else:
print "OK"
| wujide/awesome-python-webapp | demo/URLError_demo.py | Python | gpl-2.0 | 245 |
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2003-2009 Bastian Kleineidam
"""
Parameters for help.html page.
"""
from wc import AppName, Version
from wc.configuration import config
port = config.get('port', 8080)
| HomeRad/TorCleaner | wc/webgui/context/help_html.py | Python | gpl-2.0 | 215 |
# Copyright 2011 Patricio Paez <pp@pp.com.mx>
#
# Plugin to use arithmetic in Zim wiki
from zim.inc.arithmetic import ParserGTK
from zim.plugins import PluginClass
from zim.actions import action
from zim.gui.pageview import PageViewExtension
class ArithmeticPlugin(PluginClass):
plugin_info = {
'name': _('Arith... | jaap-karssenberg/zim-desktop-wiki | zim/plugins/arithmetic.py | Python | gpl-2.0 | 1,046 |
import uuid
from flask import jsonify, request
from thrive import app
from thrive.models.graph import Period
from thrive.models.transactions import spawn_periods_for_year
# --------------------------------------------------------------------------
# POST GROUP
# --------------------------------------------------------... | OneTesseractInMultiverse/Thrive | thrive/resources/period_resource.py | Python | mit | 1,413 |
from django.contrib.postgres.search import SearchQuery
from django.db.models import Count, Sum
from django.db.models import F
# from django.views.decorators.cache import cache_page
# from django.utils.decorators import method_decorator
from rest_framework import generics
from rest_framework.pagination import PageNumb... | Code4SA/municipal-data | infrastructure/views/api.py | Python | mit | 6,462 |
import random
from typing import Callable, List, Iterable, Iterator
import pandas as pd
from ray.util.iter import (_NextValueNotReady, LocalIterator, ParallelIterator,
T, U, _ActorSet, from_items)
class MLDataset(ParallelIterator[pd.DataFrame]):
"""A distributed ML dataset implemented... | pcmoritz/ray-1 | python/ray/util/data/dataset.py | Python | apache-2.0 | 16,719 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutStrings(Koan):
def test_double_quoted_strings_are_strings(self):
string = "Hello, world."
self.assertEqual(True, isinstance(string, basestring))
def test_single_quoted_strings_are_also_strings(self):
... | kritsadanshon/python_koans | python2/koans/about_strings.py | Python | mit | 3,142 |
from __future__ import unicode_literals
from django.db.models import fields
from django.utils.translation import ugettext_lazy as _
from ...models.field import FieldDefinition
class _BooleanMeta:
defined_field_category = _('Boolean')
class BooleanFieldDefinition(FieldDefinition):
class Meta(_BooleanMeta):... | charettes/django-mutant | mutant/contrib/boolean/models.py | Python | mit | 610 |
from django import template
from django.conf import settings
from django.test import TestCase
class TestTemplateTag(TestCase):
def test_tag_renders_correctly(self):
tpl = """{% load openid %}{% openid_form %}"""
self.assertTrue('form' in template.Template(tpl).render(template.Context({'req... | vinco/django-socialregistration | socialregistration/contrib/openid/tests.py | Python | mit | 960 |
# coding=utf-8
# Author: Nic Wolfe <nic@wolfeden.ca>
#
# This file is part of Medusa.
#
# Medusa 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... | pymedusa/SickRage | medusa/naming.py | Python | gpl-3.0 | 7,884 |
#!/usr/bin/env python
# Copyright (c) 2011 Stanford University
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ... | y-higuchi/ramcloud | scripts/transportgraph.py | Python | isc | 2,912 |
# This library 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, either
# version 3 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be ... | TaskEvolution/Task-Coach-Evolution | taskcoach/taskcoachlib/thirdparty/ntlm/ntlm.py | Python | gpl-3.0 | 22,441 |
import sys
from pcs.cli.common.tools import print_to_stderr
from pcs.common.reports import (
ReportItem,
ReportItemList,
ReportItemSeverity,
codes,
)
from .messages import report_item_msg_from_dto
def warn(message: str) -> None:
print_to_stderr(f"Warning: {message}")
def deprecation_warning(me... | tomjelinek/pcs | pcs/cli/reports/output.py | Python | gpl-2.0 | 1,765 |
# ==================================================================================================
# Copyright 2013 Twitter, Inc.
# --------------------------------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use thi... | WCCCEDU/twitter-commons | src/python/twitter/common/rpc/finagle/__init__.py | Python | apache-2.0 | 1,073 |
from typing import List
# Definition for a binary tree node.
class _TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def buildTree(self, inorder: List[int], postorder: List[int]) -> _TreeNode:
if not ... | AustinTSchaffer/DailyProgrammer | LeetCode/ConstructBinaryTreeFromInorderAndPostorderTraversal/app.py | Python | mit | 2,224 |
#
# Copyright 2012 New Dream Network, LLC (DreamHost)
#
# 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... | openstack/aodh | aodh/api/controllers/root.py | Python | apache-2.0 | 1,780 |
""" Tests if ReleaseData works.
When ReleaseData is set on an algorithm, its output
is supposed to be cleared by the consumer algorithm
once it is done processing it. The following test
verifies this.
"""
import vtk
from vtk.test import Testing
class TestReleaseData(Testing.vtkTest):
def test(self):
sphere... | HopeFOAM/HopeFOAM | ThirdParty-0.1/ParaView-5.0.1/VTK/Common/ExecutionModel/Testing/Python/TestReleaseData.py | Python | gpl-3.0 | 936 |
# run in terminal
export PYTHONPATH=/usr/share/qgis/python
export LD_LIBRARY_PATH=/usr/lib
# set PYTHONPATH=/usr/share/qgis/python
python
# trying to create the map canvas just using Python
import os, sys, re, webbrowser
from qgis.core import *
from osgeo import ogr
from PyQt4.QtCore import *
from PyQt4.QtGui import ... | jannes-m/RQGIS | inst/test-scripts/linux_map_canvas.py | Python | lgpl-3.0 | 4,507 |
default_app_config = 'main.apps.MainConfig'
| rit-sailing/website | main/__init__.py | Python | mit | 44 |
# -*- coding: utf-8 -*-
"""
The Pygments MoinMoin Parser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This fragment is a Docutils_ 0.4 directive that renders source code
(to HTML only, currently) via Pygments.
To use it, adjust the options below and copy the code into a module
that you import on initializatio... | ShuffleBox/django-rcsfield | rcs/wiki/lib/pygments_rest.py | Python | bsd-3-clause | 2,468 |
"""
All logic related to managing the Flask server.
"""
from __future__ import absolute_import
def start():
"""
Start the web server.
"""
pass
def stop():
"""
Stop the web server.
"""
pass
def restart():
"""
Restart the web server.
"""
pass
def status():
"""
... | starcraftman/new-awesome | util/web_control.py | Python | bsd-3-clause | 457 |
import hashlib
import hmac
import json
from .compat import constant_time_compare, string_types
from .exceptions import InvalidKeyError
from .utils import (
base64url_decode, base64url_encode, der_to_raw_signature,
force_bytes, force_unicode, from_base64url_uint, raw_to_der_signature,
to_base64url_uint
)
... | argeweb/start | argeweb/libs/jwt/algorithms.py | Python | mit | 13,440 |
import zstackwoodpecker.test_state as ts_header
import os
TestAction = ts_header.TestAction
def path():
return dict(initial_formation="template5", checking_point=1, faild_point=100000, path_list=[
[TestAction.create_mini_vm, 'vm1', 'cluster=cluster2'],
[TestAction.destroy_vm, 'vm1'],
[TestAction.recover_vm, ... | zstackio/zstack-woodpecker | integrationtest/vm/mini/multiclusters/paths/multi_path257.py | Python | apache-2.0 | 2,414 |
"""Sphinx documentation configuration."""
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup -----------------------------------------------... | HumanCompatibleAI/imitation | docs/conf.py | Python | mit | 3,217 |
"""Python script to perform MC pynoddy simulations in parallel
The script uses the python multiprocessing module and is intended for use in
supercomputer/ multi-core environemnts in a terminal/ submission job/ screen mode.
Adjusted from stackoverflow thread:
https://stackoverflow.com/questions/8533318/python-multipro... | flohorovicic/pynoddy | docs/notebooks/Pynoddy_parallel_MC.py | Python | gpl-2.0 | 6,633 |
#!/home/dlx/prj/theblog/env/bin/python
from django.core import management
if __name__ == "__main__":
management.execute_from_command_line()
| DaniilLeksin/theblog | env/bin/django-admin.py | Python | gpl-2.0 | 145 |
# version for tests, no use of State.printT
# currently uses the original key lookup which failed in the past...
import csv
print('This is FROZEN Presets.py')
class Preset():
def __init__(self,pyGuitarConf):
self.conf = pyGuitarConf
self.presets = {}
self.filePath = self.conf.LocalConf.... | gratefulfrog/ArduGuitar | Ardu2/design/POC-3_MAX395/pyboard/V1_WithHMI/pyboard/Test_or_Old/FrozenStringBug/Presets.py | Python | gpl-2.0 | 2,959 |
"""engine.SCons.Tool.msvc
Tool-specific initialization for Microsoft Visual C/C++.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any p... | timj/scons | src/engine/SCons/Tool/msvc.py | Python | mit | 11,390 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.core import validators
from django.db import models, migrations
from django.utils import timezone
class Migration(migrations.Migration):
dependencies = [
('contrib.contenttypes', '__first__'),
]
operations = [
m... | hanleybrand/mdid3-core-a-goof-around | mdid3/contrib/auth/migrations/0001_initial.py | Python | bsd-3-clause | 4,011 |
# The MIT License (MIT)
#
# Copyright (c) 2016 Sean Bell
#
# 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,... | kovibalu/cnntools | descstore.py | Python | mit | 22,390 |
""" Visualize cumulative SHAP values."""
from __future__ import division, unicode_literals
import warnings
from typing import Union
import numpy as np
try:
import matplotlib.cm as cm
import matplotlib.pyplot as pl
import matplotlib
except ImportError:
warnings.warn("matplotlib could not be loaded!")... | slundberg/shap | shap/plots/_decision.py | Python | mit | 25,998 |
from skyfield.data.gravitational_parameters import GM_dict
non_barycenters = [id for id in GM_dict.keys() if not 0 <= id <= 9]
ssb_gm = sum([GM_dict[id] for id in non_barycenters])
print(ssb_gm)
| skyfielders/python-skyfield | design/ssb_gm.py | Python | mit | 196 |
"""
Surveilr - Log aggregation, analysis and visualisation
Copyright (C) 2011 Linux2Go
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... | Linux2Go/Surveilr | surveilr/tests/test_utils.py | Python | agpl-3.0 | 3,742 |
# http://stackoverflow.com/questions/25967922/pybrain-time-series-prediction-using-lstm-recurrent-nets
from __future__ import print_function
from pybrain.datasets import SequentialDataSet
from itertools import cycle
from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure.modules import LSTMLayer
from py... | mertyildiran/Cerebrum | cerebrum/neuralnet/developmentExamples/pybrain-lstm.py | Python | mit | 1,430 |
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import weakref
a_set = {0, 1}
wref = weakref.ref(a_set)
print(wref)
print(wref())
a_set = {2, 3, 4}
print(wref())
print(wref() is None)
print(wref() is None)
class Cheese:
def __init__(self, kind):
self.kind = kind
def __repr__(self):
return... | xu6148152/Binea_Python_Project | FluentPython/object_reference_mutability_recycling/weakref_test.py | Python | mit | 647 |
# -*- coding: utf-8 -*-
import collections
import copy
import cStringIO
import datetime
import hashlib
import json
import itertools
import logging
import math
import os
import re
import sys
import textwrap
import uuid
from subprocess import Popen, PIPE
from urlparse import urlparse
import babel
import babel.dates
impo... | OpusVL/odoo | openerp/addons/base/ir/ir_qweb.py | Python | agpl-3.0 | 64,117 |
#!/usr/bin/env python3
def is_installed(path):
"""Check if a database has already been initialized"""
return False # Stub code
def init_db(path):
pass # Stub code
def reset(day):
pass
def get_config(key):
return 1
| onlyleft/pedway | backend.py | Python | mit | 238 |
__author__ = 'weiheng'
def greeting(msg):
print(msg) | weihengSu/cs3240-labdemo | helper.py | Python | mit | 57 |
# vim: set fileencoding=utf-8
from collections import defaultdict
from itertools import chain
import re
import inflection
try:
del inflection.PLURALS[
inflection.PLURALS.index(('(?i)(p)erson$', '\\1eople'))]
except ValueError:
pass
from regparser.citations import internal_citations, Label
from regpar... | willbarton/regulations-parser | regparser/layer/terms.py | Python | cc0-1.0 | 16,960 |
# $Id$
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
This module defines table parser classes,which parse plaintext-graphic tables
and produce a well-formed data structure suitable for building a CALS table.
:Classes:
- `GridTableParser`: Parse ful... | Lyleo/OmniMarkupPreviewer | OmniMarkupLib/Renderers/libs/python3/docutils/parsers/rst/tableparser.py | Python | mit | 20,977 |
# 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 t... | briancurtin/python-openstacksdk | openstack/tests/unit/compute/v2/test_server_group.py | Python | apache-2.0 | 1,883 |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
from pants.base.conf... | square/pants | src/python/pants/backend/jvm/scala/target_platform.py | Python | apache-2.0 | 1,517 |
#!/usr/bin/env python
print 'Hello Banneker!'
| timothydmorton/test-demo | myscript.py | Python | mit | 48 |
# You may redistribute this program 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 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY;... | hyperboria/python-cjdns | cjdns/key_utils.py | Python | gpl-3.0 | 998 |
"""
NetworkX
========
NetworkX is a Python package for the creation, manipulation,
and study of the structure, dynamics, and functions
of complex networks.
Website (including documentation)::
http://networkx.github.io
Mailing list::
https://groups.google.com/forum/#!forum/networkx-discuss
Source::
ht... | kenshay/ImageScript | ProgramData/SystemFiles/Python/Lib/site-packages/networkx/__init__.py | Python | gpl-3.0 | 3,178 |
#
# Copyright (c) 2010 Red Hat, 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 t... | oVirt/ovirt-engine-cli | src/ovirtcli/shell/clearcmdshell.py | Python | apache-2.0 | 873 |
# Time: O(n)
# Space: O(1)
#
# Given two binary strings, return their sum (also a binary string).
#
# For example,
# a = "11"
# b = "1"
# Return "100".
#
class Solution:
# @param a, a string
# @param b, a string
# @return a string
def addBinary(self, a, b):
result, carry, val = "", 0, 0
... | yiwen-luo/LeetCode | Python/add-binary.py | Python | mit | 761 |
"""xferfcn_test.py - test TransferFunction class
RMM, 30 Mar 2011 (based on TestXferFcn from v0.4a)
"""
import numpy as np
import pytest
import operator
import control as ct
from control.statesp import StateSpace, _convert_to_statespace, rss
from control.xferfcn import TransferFunction, _convert_to_transfer_function... | python-control/python-control | control/tests/xferfcn_test.py | Python | bsd-3-clause | 42,667 |
import importlib
def import_callable(path):
"""
:param path: the dot-notated absolute path to a callable
:returns: callable, e.g. function, class
"""
assert isinstance(path, str)
split_path = path.split('.')
module_path = ".".join(split_path[:-1])
callable_name = split_path[-1]
module = importlib.import_modu... | jbowen7/carrot | src/carrot/utils.py | Python | gpl-2.0 | 375 |
# -*- coding: utf-8 -*-
"""
This module provides functions for reading and writing Polygons in different
formats.
The following write-methods will accept different argument types for the
output. If ofile is None, the method will create and return a StringIO-object.
If ofile is a string, a file with that name will b... | tangrams/landgrab | Polygon2-2.0.7/Polygon/IO.py | Python | mit | 12,163 |
"A script that calculates allele frequencies from plink data"
import argparse
import pydigree as pyd
parser = argparse.ArgumentParser()
parser.add_argument('--ped', required=True, help='Plink formatted PED file')
parser.add_argument('--map', required=True, help='Plink formatted MAP file')
parser.add_argument('--snps... | jameshicks/pydigree | scripts/frequencies.py | Python | apache-2.0 | 1,422 |
from ophyd.device import (Component as Cpt)
from hxntools.detectors.xspress3 import (Xspress3FileStore,
Xspress3Channel)
from hxntools.detectors.hxn_xspress3 import HxnXspress3DetectorBase
import threading
from ophyd import DeviceStatus
class HxnXspress3Detector(HxnXspress3De... | NSLS-II-HXN/ipython_ophyd | startup/21-xspress3.py | Python | bsd-2-clause | 12,318 |
from __future__ import absolute_import
import abc
from .struct import Struct
from .types import Int16, Int32, String, Schema
class RequestHeader(Struct):
SCHEMA = Schema(
('api_key', Int16),
('api_version', Int16),
('correlation_id', Int32),
('client_id', String('utf-8'))
)
... | OpenBankProject/OBP-Kafka-Python | lib/kafka/protocol/api.py | Python | agpl-3.0 | 1,655 |
"""
Given a m * n matrix mat of integers,
sort it diagonally in ascending order
from the top-left to the bottom-right
then return the sorted array.
mat = [
[3,3,1,1],
[2,2,1,2],
[1,1,1,2]
]
Should return:
[
[1,1,1,1],
[1,2,2,2],
[1,2,3,3]
]
"""
from heapq import heappush, heappop
from typing ... | keon/algorithms | algorithms/matrix/sort_matrix_diagonally.py | Python | mit | 1,851 |
from echomesh.util.thread.TimeLoop import TimeLoop
from gittwit.twitter.Search import Search
class Loop(TimeLoop):
def __init__(self, search, callback, interval=2, preload=1, name='SearchLoop',
timeout=None):
super(Loop, self).__init__(name=name, timeout=timeout, interval=interval)
self.search... | rec/echomesh | code/python/external/gittwit/twitter/Loop.py | Python | mit | 413 |
# EF-SMT solver implementation
#
# This example shows:
# 1. How to combine 2 different solvers
# 2. How to extract information from a model
#
from pysmt.shortcuts import Solver, get_model
from pysmt.shortcuts import Symbol, Bool, Real, Implies, And, Not, Equals
from pysmt.shortcuts import GT, LT, LE, Minus, Times
fro... | idkwim/pysmt | examples/efsmt.py | Python | apache-2.0 | 2,475 |
"""This file contains tests for src/update_runnablejobs.py."""
import json
import os
import unittest
import datetime
import time
import logging
import shutil
from mock import patch, Mock
from tools.update_runnablejobs import (update_runnableapi,
add_new_jobs_into_pressed)
TMP_... | jmaher/ouija | tests/test_update_runnablejobs.py | Python | mpl-2.0 | 6,716 |
#
# 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... | DinoCow/airflow | airflow/providers/google/cloud/operators/cloud_memorystore.py | Python | apache-2.0 | 71,493 |
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import time
import subprocess
# Import parameters from the setup file.
sys.path.append('.')
from setup import (
setup_dict, get_project_files, print_success_message,
print_failure_message, _lint, _test, _test_all,
CODE_DIR... | hgranlund/py-chess-engine | pavement.py | Python | mit | 7,367 |
import ctypes as ct
import types
import sdl2 as sdl
import window
class EventListenerBase(object):
def quit(self):
pass
def key_up(self):
pass
def key_down(self):
pass
def window_close(self):
pass
def window_resize(self):
pass
class Events(object):
... | mdsitton/pract2d | pract2d/core/events.py | Python | bsd-2-clause | 2,800 |
#-*- coding: utf-8 -*-
__docformat__='restructuredtext'
# Migration number: 013
# New Entity Bookmark
migration = [
("""\
ALTER TABLE users ADD COLUMN quote VARCHAR(255);
""",
"""\
ALTER TABLE users DROP COLUMN quote;
"""),
]
| santisiri/popego | popego/popserver/popserver/db/migration_014.py | Python | bsd-3-clause | 261 |
import logging
from pykit import logutil
logger = logutil.make_logger('/tmp', log_fn='stdlog', level='INFO',
fmt='message')
logutil.add_std_handler(logger, 'stdout', fmt='message', level=logging.ERROR)
logger.debug('debug')
logger.info('stdlog')
logger.error('error')
| sejust/pykit | logutil/test/stdlog.py | Python | mit | 301 |
# -*- coding: utf-8 -*-
from jinja2 import Template
# 生成するHTMLのテンプレート
HTML_TEMPLATE = """\
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>詳細レポート: {{ start_date }} - {{ end_date }}</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/cs... | 7pairs/toggl2html | toggl2html/converter/detail.py | Python | apache-2.0 | 4,142 |
#!/bin/true
# -*- coding: utf-8 -*-
#
# This file is part of os-installer
#
# Copyright 2013-2016 Ikey Doherty <ikey@solus-project.com>
#
# 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, eit... | solus-project/os-installer | os_installer2/application.py | Python | gpl-2.0 | 968 |
import os
import numpy as np
images = np.zeros((0,28*28))
labels = np.zeros((0,1))
for directory in os.listdir('./temp') :
if os.path.isdir(directory):
image_filename = os.path.join(directory, 'images.csv')
label_filename = os.path.join(directory, 'labels.csv')
if os.path.isfile(image_file... | jamesrobertlloyd/kmc-research | data/mnist/many-rbm-samples/collate_results.py | Python | mit | 754 |
import os
from . import util
from latus import const
class Walker:
def __init__(self, root, do_dirs=False, ignore=None):
"""
root: the directory to start the walk from
do_dirs: if True, return directories (as opposed to only files).
ignore: a list of folder/directory names to not ... | latusrepo/latus | latus/walker.py | Python | gpl-3.0 | 2,064 |
from moneydog import app
from moneydog.models import str2category, category2str
from datetime import date
app.jinja_env.filters['str2category'] = str2category
app.jinja_env.filters['category2str'] = category2str
@app.template_filter('reverse')
def reverse_filter(s):
return s[::-1]
@app.template_fi... | Falldog/moneydog | moneydog/filters.py | Python | apache-2.0 | 463 |
__source__ = 'https://leetcode.com/problems/surface-area-of-3d-shapes/'
# Time: O()
# Space: O()
#
# Description: Leetcode # 892. Surface Area of 3D Shapes
#
# On a N * N grid, we place some 1 * 1 * 1 cubes.
#
# Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).
#
# Return the t... | JulyKikuAkita/PythonPrac | cs15211/SurfaceAreaof3DShapes.py | Python | apache-2.0 | 3,143 |
from django import forms
class FacebookConnectForm(forms.Form):
access_token = forms.CharField(required=True)
| tejesh95/Zubio.in | zubio/allauth/socialaccount/providers/facebook/forms.py | Python | mit | 116 |
from django.db import models
from six import python_2_unicode_compatible
@python_2_unicode_compatible
class TModel(models.Model):
name = models.CharField(max_length=200)
test = models.ManyToManyField(
'self',
blank=True,
related_name='related_test_models'
)
for_inline = mode... | yourlabs/django-autocomplete-light | test_project/select2_many_to_many/models.py | Python | mit | 511 |
# -*- coding: utf-8 -*-
#
# 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, softwar... | kxepal/hypothesis-couchdb | setup.py | Python | apache-2.0 | 1,951 |
"""
Tests for verified track content views.
"""
import json
import six
import pytest
from django.http import Http404
from django.test.client import RequestFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from common.djangoapps.student.tests.factories import UserFactory, AdminFactory
from xmod... | stvstnfrd/edx-platform | openedx/core/djangoapps/verified_track_content/tests/test_views.py | Python | agpl-3.0 | 2,500 |
# Copyright 2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | nikesh-mahalka/cinder | cinder/tests/unit/api/contrib/test_volume_actions.py | Python | apache-2.0 | 41,283 |
#!/usr/bin/python
"""
garage.py - a small daemon to monitor MQTT for state changes
and activates a GPIO that presumably is attached to relay for
toggling a garage door. It also assumes a reed switch is attached
to determine the garage door state.
Copyright (C) 2016 Mark G. Weber
This program is free software: you c... | markgweber/garage_door | garage.py | Python | gpl-3.0 | 5,907 |
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
##
## Copyright (C) 2012 Async Open Source <http://www.async.com.br>
## All rights reserved
##
## 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 Foundati... | tiagocardosos/stoq | stoqlib/gui/test/test_baseeditor.py | Python | gpl-2.0 | 5,747 |
# -*- coding: utf-8 -*-
import sqlalchemy as sa
from tests import ClassicTestCase, DeclarativeTestCase
class Suite(object):
def test_current_translation_as_expression(self):
query = (
self.session.query(self.Article)
.join(self.Article.current_translation)
)
assert... | kvesteri/sqlalchemy-i18n | tests/test_join_expressions.py | Python | bsd-3-clause | 2,597 |
"""
# Notes:
- This simulation seeks to emulate the COBAHH benchmark simulations of (Brette
et al. 2007) using the Brian2 simulator for speed benchmark comparison to
DynaSim. However, this simulation includes CLOCK-DRIVEN synapses, for direct
comparison to DynaSim's clock-driven architecture. The synaptic connec... | asoplata/dynasim-benchmark-brette-2007 | output/Brian2/brian2_benchmark_COBAHH_clocksyn_hidens_0002/brian2_benchmark_COBAHH_clocksyn_hidens_0002.py | Python | gpl-3.0 | 3,769 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Helper functions to get a list of dates and total number bugs open, close.
"""
__author__ = "duy <duy at rhizoma dot tk>"
__copyright__ = "GPL v3"
from datetime import datetime, date, timedelta
import argparse
from util import fetch_... | duy/debbtsstats | debbtsstats/bugsbydate.py | Python | agpl-3.0 | 3,207 |
import json
import base64
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings
from ..views import register, agents
from ..models import Agent
class AgentTests(TestCase):
@classmethod
def setUpClass(cls):
print "\n%s" % __name__
def setUp... | frasern/ADL_LRS | lrs/tests/AgentTests.py | Python | apache-2.0 | 3,199 |
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.category, name='index'),
url(r'^(?P<category>[^/]+)$', views.category, name='categories'),
url(r'^(?P<category>[^/]+)/(?P<page_name>[^/]+)$', views.page, name='page')
]
| SkyzohKey/tox-wiki | doc/urls.py | Python | mit | 268 |
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
#
# Copyright (C) 2009 Johan Dahlin <johan@gnome.org>
# 2010 Simon van der Linden <svdlinden@src.gnome.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser Ge... | jdahlin/pygobject | gi/overrides/Gtk.py | Python | lgpl-2.1 | 54,275 |
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pylab as pl; pl.close("all")
import cPickle as pickle
#data
per_norm1= pickle.load(open('/home/camacho/Dropbox/RESULTADOS/Likelihoods/4days_1spot_likes/likes_Pnormal_1.p'))
per_decay1= pickle.load(open('/home/camacho/Dropbox/RESULTADOS/Likelihoods/4days_1spo... | jdavidrcamacho/Tests_GP | 08 - Thesis results/4days_histograms.py | Python | mit | 5,334 |
'''
Created on 2015年2月3日
對齊文字
@author: Guan-yu Willie Chen
'''
def sample():
t = "Hello World"
print(t.ljust(20))
print(t.rjust(20))
print(t.center(20))
def sample1():
t = "Hello World"
print(t.rjust(20, '='))
print(t.center(20, '*'))
def sample2()... | williechen/DailyApp | 03/py201502/sample/sample1.py | Python | lgpl-3.0 | 760 |
# -*-coding:Utf-8 -*
# Copyright (c) 2014 LE GOFF Vincent
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# lis... | stormi/tsunami | src/primaires/scripting/fonctions/arrondir.py | Python | bsd-3-clause | 2,308 |
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("compiled.pyx")
)
| ldong/vim_youcompleteme | third_party/jedi/test/test_evaluate/extensions/setup.py | Python | gpl-3.0 | 120 |
# Under the PySpark shell, type:
# execfile('q2_browsing_spark.py')
import itertools
def parseSingle(line):
return [ (single, 1) for single in line.split() ]
def parseSet(line, itemSetSize=2):
return [ ((itemSet[0], itemSet), 1) for itemSet in list(itertools.permutations(line.split(), itemSetSize))]
s ... | xjlin0/cs246 | w2015/hw1/q2_browsing_spark_t2.py | Python | mit | 1,511 |
# Copyright 2017 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 by applicable law or a... | cshallue/models | research/syntaxnet/dragnn/python/trainer_lib_test.py | Python | apache-2.0 | 2,420 |
# Copyright (c) 2015, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.
import stix
from stix.data_marking import MarkingStructure
import stix.bindings.extensions.marking.tlp as tlp_binding
@stix.register_extension
class TLPMarkingStructure(MarkingStructure):
_binding = tlp_bindin... | chriskiehl/python-stix | stix/extensions/marking/tlp.py | Python | bsd-3-clause | 1,713 |
from django import template
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db.models.loading import get_model
from django.template import TemplateSyntaxError
from django.utils.functional import wraps
from relationships.models import RelationshipStatus, Relationship
... | alexandrefrigout/django-relationships | relationships/templatetags/relationship_tags.py | Python | mit | 7,202 |
# zwei 04/15/2014
# bimorphic call to functions that are local variables
def funcA():
print("do stuff A")
def funcB():
print("do stuff B")
def doCall(funcs):
for t in funcs:
t()
doCall([funcA, funcB]) | wdv4758h/ZipPy | edu.uci.python.test/src/tests/call-variable-function-test.py | Python | bsd-3-clause | 209 |
from distutils.core import setup
setup(
name='localizeit',
version='0.9.0',
author='Florian Sey',
author_email='florian.sey@gmail.com',
url='https://github.com/sey/localizeit',
description='Generate localization files for iOS and Android projects from Google Spreadsheets.',
classifiers=[
'Development Status :... | sey/localizeit | setup.py | Python | mit | 766 |
from typing import NamedTuple, List
import csv
Highscore = NamedTuple('Highscore', [('score', int), ('name', str)])
class HighscoreList:
"""A sorted list of top scores"""
def __init__(self, places: int=10) -> None:
self.scores = [] # type: List[Highscore]
self.places = places
def ad... | krother/maze_run | 16_static_typing/highscores.py | Python | mit | 1,039 |
# 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... | zhreshold/mxnet | tests/python/unittest/test_extensions.py | Python | apache-2.0 | 7,787 |
# Copyright 2018 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... | ghchinoy/tensorflow | tensorflow/python/data/kernel_tests/reduce_test.py | Python | apache-2.0 | 7,164 |
from django.contrib.auth.models import User
from django.db.models import Q
from django import forms
class MasqueradeHomeForm(forms.Form):
username_email = forms.CharField(
required = True,
error_messages = {'required': 'username/email is required.'},
)
| dineshsg/spoken-website | masquerade/forms.py | Python | gpl-3.0 | 278 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.