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 django.core.exceptions import ObjectDoesNotExist
from django.db.models import Model, NOT_PROVIDED
from django.utils.encoding import smart_text
def track_field(field):
"""
Returns whether the given field should be tracked by Auditlog.
Untracked fields are many... | robmagee/django-auditlog | src/auditlog/diff.py | Python | mit | 4,114 |
# -*- coding: utf-8 -*-
from typing import Text
from zerver.lib.test_classes import WebhookTestCase
class JiraHookTests(WebhookTestCase):
STREAM_NAME = 'jira'
URL_TEMPLATE = u"/api/v1/external/jira?api_key={api_key}"
def test_unknown(self) -> None:
url = self.build_webhook_url()
result =... | mahim97/zulip | zerver/webhooks/jira/tests.py | Python | apache-2.0 | 7,146 |
import os
import urllib
import urllib2
import cookielib
users_email_address = "username@gmail.com"
users_password = "password"
my_app_name = "wattcher"
target_authenticated_google_app_engine_uri = 'http://wattcher.appspot.com/report'
# we use a cookie to authenticate with Google App Engine
# by registering a ... | ldm5180/hammerhead | hab/killawatt/appengineauth.py | Python | lgpl-2.1 | 2,358 |
import base64
import os
# Web app
flask_host = os.getenv('FLASK_HOST', 'localhost')
flask_port = int(os.getenv('FLASK_PORT', 5000))
try:
flask_secret_key = base64.b64decode(os.getenv('FLASK_SECRET_KEY', None))
except TypeError:
raise Exception('FLASK_SECRET_KEY must be base64 encoded.')
flask_debug_mode = bo... | mccricardo/pulseguardian | pulseguardian/config.py | Python | mpl-2.0 | 2,217 |
from django.forms import Textarea
from django.utils.safestring import mark_safe
from .base import WidgetTest
class TextareaTest(WidgetTest):
widget = Textarea()
def test_render(self):
self.check_html(self.widget, 'msg', 'value', html=(
'<textarea rows="10" cols="40" name="msg">value</tex... | Beauhurst/django | tests/forms_tests/widget_tests/test_textarea.py | Python | bsd-3-clause | 1,313 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
##############################################################################
from distutils.core import setup, Extension
##############################################################################
VERSION = '1.0'
EXTRA_COMPILE_ARGS = [
'-Wall',
'-fno-stric... | alexin-ivan/ether | setup.py | Python | mit | 1,363 |
# -*- test-case-name: twisted.runner.test.test_procmon -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Support for starting, monitoring, and restarting child process.
"""
from twisted.python import log
from twisted.internet import error, protocol, reactor as _reactor
from twisted.applic... | Tokyo-Buffalo/tokyosouth | env/lib/python3.6/site-packages/twisted/runner/procmon.py | Python | mit | 10,089 |
from tools.load import LoadMatrix
lm=LoadMatrix()
traindat = lm.load_numbers('../data/fm_train_real.dat')
testdat = lm.load_numbers('../data/fm_test_real.dat')
label_traindat = lm.load_labels('../data/label_train_multiclass.dat')
parameter_list = [[traindat,testdat,label_traindat],[traindat,testdat,label_traindat]]
... | ratschlab/ASP | examples/undocumented/python_modular/classifier_conjugateindex_modular.py | Python | gpl-2.0 | 905 |
"""
The history module gathers all functionalities related to the organization of time series data that
are used by the simulator and by the forecasters.
"""
from .database import Database
__all__ = [
'Database'
]
| bcornelusse/microgrid-bench | microgrid/history/__init__.py | Python | bsd-2-clause | 220 |
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from tastypie.api import Api
from accounts.api import UserResource, GroupResource, ProfileResource, ObjectProfileLinkResource
# from alambic.api import RoomR... | CommonsDev/dataserver | dataserver/urls.py | Python | agpl-3.0 | 3,425 |
###########################################################
#
# Copyright (c) 2005, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permi... | sadanandb/pmt | src/tactic/ui/app/undo_log_wdg.py | Python | epl-1.0 | 4,731 |
# -*- coding: utf-8 -*-
from lektor.pluginsystem import Plugin
from markupsafe import Markup
SCRIPT = '''
<div id="ga-script"></div>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.... | kmonsoor/lektor-google-analytics | lektor_google_analytics.py | Python | bsd-3-clause | 1,491 |
import json
import os
import urlparse
import re
import webdriver
import mozlog
from tests.support.asserts import assert_error
from tests.support.http_request import HTTPRequest
from tests.support import merge_dictionaries
default_host = "http://127.0.0.1"
default_port = "4444"
logger = mozlog.get_default_logger()
... | n0max/servo | tests/wpt/web-platform-tests/webdriver/tests/support/fixtures.py | Python | mpl-2.0 | 8,260 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-03 13:54
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('news', '0030_auto_20160503_1235'),
]
operations = [... | kwameboame/newsdex | news/migrations/0031_auto_20160503_1354.py | Python | bsd-2-clause | 1,422 |
# -*- coding: utf-8 -*-
#
# JSONBOT documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 2 23:24:35 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't picklea... | Petraea/jsonbot | docs/conf.py | Python | mit | 8,088 |
#!/usr/bin/env python
# Copyright (C) 2014:
# Gabes Jean, naparuba@gmail.com
import traceback
from opsbro_test import *
from opsbro.evaluater import evaluater
class TestEvaluater(OpsBroTest):
def setUp(self):
pass
def test_evaluator(self):
rules = [
{'rule': '1+1', '... | naparuba/kunai | test/test_evaluator.py | Python | mit | 3,577 |
import logging
from configparser import ConfigParser
from typing import Optional
from pathlib import Path
import os
from click import UsageError
class CLIConfig:
def __init__(self, config_content):
assert isinstance(config_content, str)
self.host = ''
self.username = ''
self.pa... | islog/leosac | python/leosacpy/cli/cli_config.py | Python | agpl-3.0 | 1,918 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models imp... | gustavofonseca/scielo-manager | scielomanager/journalmanager/migrations/0013_fix_nulls_in_twitter_user.py | Python | bsd-2-clause | 33,524 |
import os, sys, logging, traceback
import json
import math
import itertools
from multiprocessing import Pool
from clint.textui import progress
from PIL import Image
from doit import get_var
from . import tilesets
from uristmaps.config import conf
paths = conf["Paths"] # Reference to that conf section to make the ... | dominiks/uristmaps | uristmaps/render_sat_layer.py | Python | gpl-3.0 | 6,677 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-06-29 17:46
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('polls', '0025_question_poll_algorithm'),
('polls', '0025_item_image'),
]
operations ... | PrefPy/opra | compsocsite/polls/migrations/0026_merge.py | Python | mit | 330 |
from wtforms import (
BooleanField,
HiddenField,
MultipleFileField,
StringField,
TextAreaField,
)
from wtforms.validators import InputRequired
from CTFd.forms import BaseForm
class PageEditForm(BaseForm):
title = StringField(
"Title", description="This is the title shown on the naviga... | LosFuzzys/CTFd | CTFd/forms/pages.py | Python | apache-2.0 | 983 |
'''Main module containing the class Program(), which allows the conversion from
ordinary Python functions into commands for the command line. It uses
:py:module:``argparse`` behind the scenes.'''
import sys
import inspect
import argparse
try:
from itertools import izip_longest
except ImportError: # pragma: no cov... | GbalsaC/bitnamiP | venv/lib/python2.7/site-packages/mando/core.py | Python | agpl-3.0 | 6,201 |
__author__ = 'Dani'
class DatasetUserFileGroup(object):
def __init__(self, dataset, user, file_path):
self.dataset = dataset
self.user = user
self.file_path = file_path | landportal/landbook-importers | old-importers/IpfriExtractor/es/weso/translator/dataset_user_pair.py | Python | mit | 200 |
from time import time
from datetime import datetime
from mock import patch, Mock, sentinel
from nose import tools
from eventtracker.tasks import track, collect_events
from eventtracker.models import save_event
@patch('eventtracker.tasks._get_carrot_object')
def test_track_sends_event(get_carrot_object):
get_carro... | ella/django-event-tracker | tests/test_tasks.py | Python | bsd-3-clause | 2,486 |
import sys
import os
def is_logfile(f):
f = f.lower()
return f.startswith('awr_jobscheduler') and f.endswith('.txt')
def expand_file_list(file_args):
file_list = []
for f in file_args:
if os.path.isfile(f):
if is_logfile(f):
file_list.append(f)
elif os.pat... | danecollins/awrjs | js/util.py | Python | mit | 868 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('feti', '0017_auto_20150601_1252'),
]
operations = [
migrations.AlterField(
model_name='course',
name... | lucernae/feti | django_project/feti/migrations/0018_auto_20150601_1253.py | Python | bsd-2-clause | 470 |
# (c) Nelen & Schuurmans. GPL licensed, see LICENSE.txt.
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
# from django.core.urlresolvers import reverse
admin.autodiscover()
crumbs_waterbalance = [
{'name': 'home', 'url': '/', 'title': 'hoofdpagina'},
... | lizardsystem/lizard-waterbalance | lizard_waterbalance/urls.py | Python | gpl-3.0 | 4,274 |
# -*- test-case-name: twisted.web.test.test_static -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Static resources for L{twisted.web}.
"""
from __future__ import division, absolute_import
import os
import warnings
import itertools
import time
import errno
import mimetypes
from zope.... | Architektor/PySnip | venv/lib/python2.7/site-packages/twisted/web/static.py | Python | gpl-3.0 | 35,214 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from djangovirtualpos import views as djangovirtualpos_views
from djshop.apps.club.models import CreditCardReference
from djshop.apps.sale.models import Sale
@csr... | diegojromerolopez/djshop | src/djshop/apps/club/views/credit_card_references.py | Python | mit | 1,420 |
# Copyright (C) 2011 Jayson Vaughn <vaughn.jayson@gmail.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, either version 3 of the License, or
# (at your option) any later version.
#
# This ... | thedonvaughn/cover_grabber | tests/__init__.py | Python | gpl-3.0 | 698 |
#!/usr/bin/python
"""
This script receives as input a list of URLs and gives as output the pages
downloaded. It is a sort of simplified crawler. The pages are output in text
format, not in HTML, because our goal is to use text processing tools on it.
The output format is a folder with a set of
"""
# TODO: separat... | ceramisch/CAMELEON-cc | bin/new_download.py | Python | gpl-3.0 | 20,346 |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | yugangw-msft/azure-cli | src/azure-cli/azure/cli/command_modules/storage/_format.py | Python | mit | 4,592 |
# /setup.py
#
# Installation and setup script for polysquare-cmake-linter
#
# See LICENCE.md for Copyright information
"""Installation and setup script for polysquare-cmake-linter."""
from setuptools import find_packages
from setuptools import setup
setup(name="artificial-intelligence",
version="0.0.1",
d... | smspillaz/artificial-intelligence | setup.py | Python | mit | 1,589 |
from slackbot.bot import listen_to
@listen_to("has joined the channel")
def hello_message(message):
channel_body = getattr(message.channel, "_body", None)
if channel_body['name'] == u'arc_잡담':
username = u'<@{}>'.format(message._get_user_id())
msg = "%s 님 안녕하세요! 자기소개 부탁드려요~ @_@" % username
... | HI-ARC/hiarcbot | hiarcbot/plugins/say_hello.py | Python | apache-2.0 | 376 |
'''
Created on 05-May-2016
@author: dgraja
'''
from django.shortcuts import render
from django.core.mail import send_mail
def compose_email(request):
"""
Compose and send emails
"""
data = {"sender": "",
"to": "",
"cc": "",
"subject": "",
"body": "... | rajadg/Python | django01/application/simple/mailer.py | Python | gpl-3.0 | 890 |
# TODO : TRANSFORM INTO A CLASS AND CREATE A REPORT OF REGION TRIMMED
#~~~~~~~GLOBAL IMPORTS~~~~~~~#
# Standard library packages import
from os import remove, path
import gzip
from time import time
from sys import stdout
# Third party package import
from Bio import SeqIO
# Local library packages import
from pyDNA.U... | a-slide/pyDNA | RefMasker.py | Python | gpl-2.0 | 3,819 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-15 12:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0001_initial'),
]
operations = [
migrations.CreateModel(
... | skyrred/django_local_library | blog/migrations/0002_post2.py | Python | gpl-3.0 | 890 |
# Imports operators dynamically while keeping the package API clean,
# abstracting the underlying modules
from airflow.utils import import_module_attrs as _import_module_attrs
# These need to be integrated first as other operators depend on them
_import_module_attrs(globals(), {
'check_operator': [
'CheckO... | bellhops/airflow | airflow/operators/__init__.py | Python | apache-2.0 | 2,163 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import json
import time
import os
from collections import namedtuple
# Python 2/3 compatibility
# Python 2:
try:
from urlparse import urlparse
from urllib import urlencode
from urllib2 import urlopen, Request, HTTPError
exce... | kastnerkyle/discrete-opt | week2/submit.py | Python | bsd-3-clause | 13,804 |
#!/usr/bin/env python
#from distutils.core import setup
from setuptools import setup, find_packages
setup(name='LitleSdkPython',
version='9.12.1',
description='Vantiv eCommerce SDK for Python',
author='Vantiv eCommerce',
author_email='SDKSupport@vantiv.com',
url='https://developer.vantiv.... | LitleCo/litle-sdk-for-python | setup.py | Python | mit | 1,419 |
#!/usr/bin/python
# Send all 0 to the ledpanel
buf=bytearray(32*32*3)
out_file = open("/sys/class/ledpanel/rgb_buffer","w")
out_file.write(buf)
out_file.close()
| tanzilli/led-utils | off.py | Python | gpl-2.0 | 162 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-14 01:54
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import storage.models.labels
class Migration(migrations.Migration):
dependencies = [
('storage', '0014_auto_20170914_... | MartinPaulo/resplat | storage/migrations/0015_auto_20170914_0154.py | Python | lgpl-3.0 | 1,300 |
from media_tree.models import FileNode
from media_tree.contrib.views.listing import FileNodeListingView
from media_tree.contrib.views.detail import FileNodeDetailView
from media_tree.contrib.views.detail.image import ImageNodeDetailView
from django.views.generic.base import TemplateView
from django.conf.urls import pat... | bittner/django-media-tree | demo_project/demo_project/urls.py | Python | bsd-3-clause | 1,273 |
# Copyright (c) Mathias Kaerlev 2011-2012.
# This file is part of pyspades.
# pyspades 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... | NateShoffner/PySnip | feature_server/commands.py | Python | gpl-3.0 | 32,822 |
import math
import string
import sys
import struct
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as pyplot
import matplotlib.colors as pycolors
import matplotlib.cm as cm
import matplotlib.patches as patches
import numpy as np
import cPickle
import asciitable
import scipy.ndimage
import scipy.stats ... | gsnyder206/mock-surveys | original_illustris/hdst_mockudf.py | Python | mit | 21,619 |
import sys
sys.path.append('./lib')
import unittest
import mock
from lib import FileTransport
from StringIO import StringIO
class TestInputTransport(unittest.TestCase):
def test_construct(self):
transport = FileTransport('input', 'output')
self.assertIsNotNone(transport)
self.assertEqual('i... | Youhana-Hana/interpolation | test/test_FileTransport.py | Python | mit | 880 |
#!/usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# ***** END LICENSE BLOCK *****
"""fx_desktop_build.py.
script h... | lissyx/build-mozharness | scripts/fx_desktop_build.py | Python | mpl-2.0 | 6,956 |
# 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
# d... | wolverineav/neutron | neutron/db/sqlalchemytypes.py | Python | apache-2.0 | 2,356 |
def osdetect(buildout):
import sys
import platform
import os
platforms = ['default']
if sys.platform == 'darwin':
platforms.insert(0, 'darwin')
mac_ver = platform.mac_ver()
if mac_ver[0].startswith('10.5'):
platforms.insert(0, 'darwin-leopard')
elif mac_v... | upiq/plonebuild | python/src/osdetect.py | Python | mit | 2,246 |
'''
LICENSING
-------------------------------------------------
daemoniker: Cross-platform daemonization tools.
Copyright (C) 2016 Muterra, Inc.
Contributors
------------
Nick Badger
badg@muterra.io | badg@nickbadger.com | nickbadger.com
This library is free software; you can redistri... | Muterra/py_daemoniker | daemoniker/__init__.py | Python | unlicense | 2,633 |
#
# Album_Sound_CheckAppDelegate.py
# Album Sound Check
#
# Created by Scott Robertson on 1/17/09.
# Copyright __MyCompanyName__ 2009. All rights reserved.
#
from Foundation import *
from AppKit import *
class Album_Sound_CheckAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
NS... | spr/album-sound-check | Album_Sound_CheckAppDelegate.py | Python | gpl-2.0 | 361 |
from django.urls import re_path
from . import views
urlpatterns = [re_path(r"^/vote/(?P<username>\w+)/(?P<position>.+)$", views.vote_for_user, name="vote_for_user")]
| tjcsl/ion | intranet/apps/nomination/urls.py | Python | gpl-2.0 | 168 |
"""Core functions of mtorrentd."""
import os
import importlib.util
import libtorrent
import tempfile
import shutil
import requests
from urllib import parse
from sys import exit
from time import sleep
from .paths import SITE_MODULES
def session_login(site, username, password, session):
"""When login is needed f... | arivarton/multi-torrent-downloader | mtorrentd/core.py | Python | gpl-3.0 | 3,987 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-01-30 19:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shuup', '0029_personcontact_names'),
]
operations = [
migrations.AlterField... | shoopio/shoop | shuup/core/migrations/0030_add_db_indices.py | Python | agpl-3.0 | 910 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from rtv.clipboard import copy_linux, copy_osx
from rtv.exceptions import ProgramError
try:
from unittest import mock
except ImportError:
import mock
def test_copy():
with mock.patch('subprocess.Popen') as Popen, \
... | michael-lazar/rtv | tests/test_clipboard.py | Python | mit | 1,238 |
# Copyright (C) 2011-2015 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman 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 you... | khushboo9293/mailman | src/mailman/model/tests/test_address.py | Python | gpl-3.0 | 2,260 |
"""
As described in
http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html
"""
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")
app = Celery("{{ cookiecutter.project_name }}")
# Using a string here means the worker will not have to
# pickle t... | mitodl/cookiecutter-djangoapp | {{ cookiecutter.project_name }}/main/celery.py | Python | bsd-2-clause | 442 |
# Copyright (c) 2017, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | DistributedSystemsGroup/zoe | zoe_api/zapp_shop.py | Python | apache-2.0 | 4,947 |
# -*- coding: utf-8 -*-
import unittest
from collections import deque
class Pilha():
def __init__(self):
self._lista = deque()
def __len__(self):
return len(self._lista)
def vazia(self):
return not bool(self._lista)
def topo(self):
if self._lista:
return... | trgomes/estrutura-de-dados | aula4/pilha.py | Python | mit | 1,658 |
#encoding: utf-8
import plugnplay
import os
from ..core import Plugin, log
import sys
class IAppLoader(plugnplay.Interface):
"""
Main interface for implementing an additional WSGI app loader
"""
def can_load(self, app_path):
'''
Return True/False if a custom load is able to load
... | daltonmatos/wsgid | wsgid/loaders/__init__.py | Python | bsd-3-clause | 2,821 |
#! /usr/bin/env python
# This file is part of the dvbobjects library.
#
# Copyright © 2005-2013 Lorenzo Pallara l.pallara@avalpa.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; either ve... | 0xalen/opencaster_isdb-tb | libs/dvbobjects/dvbobjects/utils/MJD.py | Python | gpl-2.0 | 1,057 |
"""
Generate header file with macros defining MicroPython version info.
This script works with Python 2.6, 2.7, 3.3 and 3.4.
"""
from __future__ import print_function
import sys
import os
import datetime
import subprocess
def get_version_info_from_git():
# Python 2.6 doesn't have check_output, so check for that... | turbinenreiter/micropython | py/makeversionhdr.py | Python | mit | 3,555 |
import unittest
from tree import TreeNode
class Solution:
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
return max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1
class Test(unittest.TestCase):
d... | chrisxue815/leetcode_python | problems/test_0104_recursive.py | Python | unlicense | 631 |
#
# This is an extension to the Nautilus file manager to allow better
# integration with the Subversion source control system.
#
# Copyright (C) 2006-2008 by Jason Field <jason@jasonfield.com>
# Copyright (C) 2007-2008 by Bruce van der Kooij <brucevdkooij@gmail.com>
# Copyright (C) 2008-2010 by Adam Plumb <adamplumb@... | CloCkWeRX/rabbitvcs | rabbitvcs/__init__.py | Python | gpl-2.0 | 2,964 |
# -*- coding: utf-8 -*-
# Copyright 2020 Green Valley Belgium NV
#
# 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... | our-city-app/oca-backend | src/rogerthat/exceptions/news.py | Python | apache-2.0 | 3,868 |
#!/usr/bin/env python
import sys, os
from glob import glob
try:
import setuptools
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup
NAME = 'msgpack-numpy'
VERSION = '0.3.6'
AUTHOR = 'Lev Givon'
AUTHOR_EMAIL = ... | pombredanne/msgpack-numpy | setup.py | Python | bsd-3-clause | 1,407 |
#!/usr/bin/python3
# get the filename from command line
import sys
file_in = sys.argv[1]
# imports
import listener
myListener = listener.Listener()
myListener.getAudioData(file_in)
myListener.calculateStats()
myListener.printStats()
#print('comparing against "zero" file that is as low noise as possible')
#myListen... | austinmroczek/pauser | testStats.py | Python | mit | 402 |
# Copyright (C) 2010-2011 Richard Lincoln
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish... | rwl/PyCIM | CIM14/ENTSOE/StateVariables/Wires/__init__.py | Python | mit | 1,629 |
def check_all_rows(grid):
i = 0
while i < len(grid):
j = 0
dic = set()
while j < len(grid[i]):
if grid[i][j] != '.' and grid[i][j] in dic:
return False
else:
dic.add(grid[i][j])
j += 1
i += 1
return True
de... | emirot/codefights | interviewPractice/sudoku2.py | Python | apache-2.0 | 1,688 |
# Copyright 2017 Kensho Technologies, Inc.
import unittest
from schematics.exceptions import ConversionError, ValidationError
from schematics.types import StringType, IntType
from grift.property_types import DictType, ListType, HTTPType
class TestDictType(unittest.TestCase):
def test_dict(self):
d = {'a... | cranti/grift | grift/tests/test_property_type.py | Python | apache-2.0 | 3,673 |
import numpy
import sys
from mmdlab.datareader import readfile_metgas_boxes
from mmdlab.utils import showable
from mmdlab.utils import saveimg
from mmdlab.utils import offscreen
from mmdlab.utils import init_mlab_scene
from mayavi import mlab
import time
import pylab
from numba import jit
from numba import float64, ... | detorto/mdvis | src/draw_points.py | Python | mit | 1,207 |
"""
Python 'utf-32' Codec
"""
import codecs, sys
### Codec APIs
encode = codecs.utf_32_encode
def decode(input, errors='strict'):
return codecs.utf_32_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def __init__(self, errors='strict'):
codecs.IncrementalEncoder.__ini... | Microvellum/Fluid-Designer | win64-vc/2.78/python/lib/encodings/utf_32.py | Python | gpl-3.0 | 5,128 |
from itertools import chain
from django.test import Client, TestCase
from django.core.urlresolvers import reverse
from users.models import User
from problems.models import Problem
from courses.models import ProblemSet, Course
# Create your tests here.
class BasicViewsTestCase(TestCase):
fixtures = []
def set... | ul-fmf/projekt-tomo | web/web/tests.py | Python | agpl-3.0 | 6,921 |
'''
Created on Jul 18, 2011
@author: andi
'''
__all__ = [ "log", "notify", "htmldecode", "fetchHttp",
"getUID", "getPersistent", "setPersistent", "sayHi"]
import os, re, time
import threading
import urllib, urllib2, HTMLParser
import datetime
import uuid
import xbmc, xbmcaddon
import simplejson as json
... | skandi/xbmc-addon-mindmadetools | lib/mindmade.py | Python | gpl-3.0 | 3,544 |
from __future__ import absolute_import, division, print_function
import os
from bcolz import ctable, carray
import numpy as np
from toolz import keyfilter
import datashape
from datashape import discover
import shutil
from ..numpy_dtype import dshape_to_numpy
from ..append import append
from ..convert import convert, o... | ContinuumIO/odo | odo/backends/bcolz.py | Python | bsd-3-clause | 3,424 |
#!/usr/bin/env python
import analyze_conf
import sys
import datetime, glob, job_stats, os, subprocess, time
import numpy
import scipy, scipy.stats
import argparse
import re
import multiprocessing
import functools
import tspl, tspl_utils, imbalance, masterplot, uncorrelated
def do_mp(arg):
(file,thresh,out_dir)=arg
... | ubccr/tacc_stats | analyze/process_pickles/nightly.py | Python | lgpl-2.1 | 2,983 |
# Copyright (c) 2018 Charles University, Faculty of Arts,
# Institute of the Czech National Corpus
# Copyright (c) 2018 Tomas Machalek <tomas.machalek@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as publis... | ufal/lindat-kontext | lib/plugins/rdbms_corparch/__init__.py | Python | gpl-2.0 | 20,019 |
from __future__ import absolute_import, division, print_function, with_statement
import contextlib
import functools
import sys
import textwrap
import time
import platform
import weakref
from tornado.concurrent import return_future
from tornado.escape import url_escape
from tornado.httpclient import AsyncHTTPClient
fr... | Drvanon/Game | venv/lib/python3.3/site-packages/tornado/test/gen_test.py | Python | apache-2.0 | 28,352 |
from . import accounting
from . import proc
from . import sessions
| borg-project/borg | borg/unix/__init__.py | Python | mit | 68 |
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Christophe Lampin
#
# This file is part of weboob.
#
# weboob 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, or
# (at... | blckshrk/Weboob | modules/ameli/pages.py | Python | agpl-3.0 | 5,953 |
#!/usr/bin/env python
from setuptools import setup
import os
from sbp.version import VERSION
CLASSIFIERS = [
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
... | swift-nav/libsbp | python/setup.py | Python | lgpl-3.0 | 1,535 |
import logging
class EventError(Exception):
"""Exception class for event handling errors.
Attributes:
message -- explanation of the error
"""
def __init__(self, message):
self.message = message
class EventHandler:
"""
Handler of events. Can listen to an REST endpoint, proces... | inphinitum/audio-device-controller | audio_device_controller/events.py | Python | gpl-2.0 | 8,110 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-06 20:41
from __future__ import unicode_literals
from django.db import migrations, connection
def _table_exists(db_cursor, tablename):
"Returns bool if table exists or not"
return tablename in connection.introspection.table_names()
class Migra... | feend78/evennia | evennia/comms/migrations/0015_auto_20170706_2041.py | Python | bsd-3-clause | 1,091 |
#Copyright 2009 Humanitarian International Services Group
#
#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... | mattmillr/utaka | src/exceptions/BadRequestException.py | Python | apache-2.0 | 11,951 |
#!/usr/bin/env python3
# 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... | t1m0thyj/aiyprojects-raspbian | src/aiy/assistant/device_helpers.py | Python | apache-2.0 | 3,681 |
# -*- coding: utf-8 -*-
""" Logging module for the remote control """
import logging
REMOTE_LOG = logging.getLogger("REMOTE_LOG")
| LoiX07/photobooth | tools/remote_log.py | Python | gpl-3.0 | 132 |
# -*- coding: utf8 -*-
# This file is part of PYBOSSA.
#
# Copyright (C) 2015 Scifabric LTD.
#
# PYBOSSA 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, or
# (at your op... | PyBossa/pybossa | pybossa/model/task.py | Python | agpl-3.0 | 2,582 |
#!/usr/bin/python
#
# The Crawler
#
from __future__ import with_statement
from contextlib import closing
from HTMLParser import HTMLParser
import gzip
import shelve
import math
import sys
import urlmanager
import re
#class myParser(HTMLParser):
class WebNode(HTMLParser):
words = dict()
wc = 0
ti... | sillyfellow/interesting_problems | Python/tfidf/crawler.py | Python | gpl-2.0 | 6,085 |
# Rekall Memory Forensics
# Copyright (c) 2008-2011 Volatile Systems
# Copyright 2013 Google Inc. 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 Foundation; either version 2 of the L... | rlugojr/rekall | rekall-core/rekall/plugins/overlays/windows/win7.py | Python | gpl-2.0 | 15,295 |
#!/usr/bin/env python3
'''
test_asset_mapper
----------------------------------
Tests for `asset_mapper` module.
'''
import unittest
import subprocess
import sys
import os
from os import path
from bs4 import BeautifulSoup
sys.path.append(path.join(path.dirname(__file__), '..'))
from ramlpreparer.builders.asset_mapp... | nimbinatus/deconst-raml-preparer | tests/test_asset_mapper.py | Python | apache-2.0 | 1,256 |
from sympy import Expr, Symbol
from sympy.core.decorators import call_highest_priority
class Higher(Expr):
_op_priority = 20.0
result = 'high'
@call_highest_priority('__rmul__')
def __mul__(self, other):
return self.result
@call_highest_priority('__mul__')
def __rmul__(self, other):
... | GbalsaC/bitnamiP | venv/lib/python2.7/site-packages/sympy/core/tests/test_priority.py | Python | agpl-3.0 | 2,085 |
""" This module contains the function
to generate core-shell A@B nanoparticle with FCC structure.
"""
from __future__ import print_function
import random
import copy
from math import sqrt
from ase.neighborlist import NeighborList
from ase.cluster.cubic import FaceCenteredCubic
import numpy as np
from qsar import QSA... | lavakyan/ase-bimetall | coreshell.py | Python | gpl-2.0 | 20,123 |
"""
module sdk
"""
from . import wandb_helper as helper # noqa: F401
from .wandb_alerts import AlertLevel # noqa: F401
from .wandb_artifacts import Artifact # noqa: F401
from .wandb_config import Config # noqa: F401
from .wandb_init import _attach, init # noqa: F401
from .wandb_login import login # noqa: F401
fr... | wandb/client | wandb/sdk/__init__.py | Python | mit | 720 |
def nn(mat,i,j,di,inv):
r=0
if j<yLen/di
for c in di:
r*=2
r+=mat[i][j*di+c]
return r
def compressedMat(mat):
xLen=len(mat)
yLen=len(mat[0])
yl=yLen/16+1
tab=[nn(mat,i,j,16,0) for j in xrange(yl) for i in range(xLen))]
| craigfreilly/masters-project-submission | src/KnotTheory/HFK-Zurich/fastMat.py | Python | mit | 297 |
# This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import ast
import re
from collections import Counter
from contextlib import contextmanager
from babel imp... | indico/indico | indico/util/i18n.py | Python | mit | 10,760 |
from collections import deque
import time
import requests
# Constants
BRAZIL = 'br'
EUROPE_NORDIC_EAST = 'eune'
EUROPE_WEST = 'euw'
KOREA = 'kr'
LATIN_AMERICA_NORTH = 'lan'
LATIN_AMERICA_SOUTH = 'las'
NORTH_AMERICA = 'na'
OCEANIA = 'oce'
RUSSIA = 'ru'
TURKEY = 'tr'
# Platforms
platforms = {
BRAZIL: 'BR1',
EUR... | gnozell/Yar-Ha-Har | lib/riotwatcher/riotwatcher.py | Python | mit | 22,700 |
"""
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 2: Which telephone number spent the ... | manishbisht/Udacity | Data Structures and Algorithms Nanodegree/P1 - Unscramble Computer Science Problems/Task2.py | Python | mit | 1,119 |
import pytest
from deathstar.utils import beautify_json
@pytest.mark.asyncio
async def test_listeners(empire):
r = await empire.listeners.create(name="DeathStar-Test", additional={"Port": 8989})
r = await empire.listeners.get("DeathStar-Test")
assert "error" not in r
await empire.listeners.kill("Deat... | byt3bl33d3r/DeathStar | tests/test_empire_api.py | Python | gpl-3.0 | 1,499 |
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals, print_function
from . import base
class CompleteMixin(object):
def complete(self, template_id=None):
if template_id:
data = {'complete': {'template_id': template_id}}
else:
data = {'complete': {}}
se... | lociii/billomat | billomat/mixins.py | Python | mit | 1,428 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#***************************************************************************
#* *
#* Copyright (c) 2015 Yorik van Havre <yorik@uncreated.net> *
#* ... | bblacey/FreeCAD-MacOS-CI | src/Mod/AddonManager/AddonManager.py | Python | lgpl-2.1 | 27,781 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.