code stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 226 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k |
|---|---|---|---|---|---|
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.template.base import TokenType, render_value_in_context
from django.template.defaulttags import token_kwargs
from django.utils import translation
from django.utils.safestring import SafeData, mark_safe
... | theo-l/django | django/templatetags/i18n.py | Python | bsd-3-clause | 19,087 |
# 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.
''' Base class for postprocessing of RC files.
'''
from __future__ import print_function
class PostProcessor(object):
''' Base class for postprocessi... | scheib/chromium | tools/grit/grit/tool/postprocess_interface.py | Python | bsd-3-clause | 1,031 |
"""This module contains code from
Think Python by Allen B. Downey
http://thinkpython.com
Copyright 2012 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
import math
try:
# see if Swampy is installed as a package
from swampy.TurtleWorld import *
except ImportError:
# otherwise ... | simontakite/sysadmin | pythonscripts/thinkpython/pie.py | Python | gpl-2.0 | 1,636 |
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
# Copyright 2019 Fortinet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the Lic... | Dhivyap/ansible | lib/ansible/modules/network/fortios/fortios_user_security_exempt_list.py | Python | gpl-3.0 | 13,462 |
# Copyright 2015 Dell 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 agree... | nikesh-mahalka/cinder | cinder/volume/drivers/dell/dell_storagecenter_iscsi.py | Python | apache-2.0 | 7,849 |
#
# 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 ... | protochron/aurora | src/main/python/apache/thermos/cli/commands/status.py | Python | apache-2.0 | 4,163 |
"""
Python wrappers for Orthogonal Distance Regression (ODRPACK).
Notes
=====
* Array formats -- FORTRAN stores its arrays in memory column first, i.e. an
array element A(i, j, k) will be next to A(i+1, j, k). In C and, consequently,
NumPy, arrays are stored row first: A[i, j, k] is next to A[i, j, k+1]. For
ef... | asnorkin/sentiment_analysis | site/lib/python2.7/site-packages/scipy/odr/odrpack.py | Python | mit | 41,254 |
import subprocess, os
class GpgError(Exception):
pass
class ExecutionError(GpgError):
def __init__(self, errcode):
self.error_code = errcode
def sign(input_file, extra_args=[]):
cmd = ['gpg', '--sign']
cmd.extend(extra_args)
cmd.append(input_file)
process = subprocess.Popen(cmd,
... | Sarvatt/backports | lib/bpgpg.py | Python | gpl-2.0 | 625 |
# Copyright (C) 2009 Google Inc. 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 list of conditions and the f... | danialbehzadi/Nokia-RM-1013-2.0.0.11 | webkit/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py | Python | gpl-3.0 | 22,259 |
"""Media player support for Panasonic Viera TV."""
import logging
from panasonic_viera import Keys
from homeassistant.components.media_player import DEVICE_CLASS_TV, MediaPlayerEntity
from homeassistant.components.media_player.const import (
MEDIA_TYPE_URL,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_P... | lukas-hetzenecker/home-assistant | homeassistant/components/panasonic_viera/media_player.py | Python | apache-2.0 | 5,620 |
from __future__ import absolute_import
from django.contrib import admin
from django.contrib.admin.models import DELETION
from django.contrib.auth.models import Permission
from django.core.urlresolvers import reverse
from django.utils.html import escape
from osf.models import AdminLogEntry
from osf.models import Admin... | TomBaxter/osf.io | admin/common_auth/admin.py | Python | apache-2.0 | 2,590 |
import bench
def test(num):
for i in iter(range(num // 10000)):
l = [0] * 1000
l2 = bytes(l)
bench.run(test)
| kerneltask/micropython | tests/internal_bench/from_iter-5-bytes_bound.py | Python | mit | 133 |
#!/usr/bin/python
"""
This is a unittest for qemu_qtree library.
:author: Lukas Doktor <ldoktor@redhat.com>
:copyright: 2012 Red Hat, Inc.
"""
__author__ = """Lukas Doktor (ldoktor@redhat.com)"""
import unittest
import common
from autotest.client.shared.test_utils import mock
import qemu_qtree
OFFSET_PER_LEVEL = qe... | ypu/virt-test | virttest/qemu_qtree_unittest.py | Python | gpl-2.0 | 10,740 |
#!/bin/env python
# -*- python -*-
#
# Copyright 2003,2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio 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, or (... | manojgudi/sandhi | modules/gr36/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py | Python | gpl-3.0 | 4,373 |
from ajenti.api import *
from ajenti.com import *
class DebianNetworkCfg(Plugin):
implements(IConfigurable)
name = 'Network'
id = 'network'
platform = ['Debian', 'Ubuntu']
def list_files(self):
dir = '/etc/network/'
return [dir+'*', dir+'*/*', dir+'*/*/*']
| DVSBA/ajenti | plugins/network/recovery.py | Python | lgpl-3.0 | 305 |
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | jonparrott/google-cloud-python | websecurityscanner/google/cloud/__init__.py | Python | apache-2.0 | 746 |
import mock
from nose.tools import eq_
import amo.tests
from lib.es.models import Reindexing
class TestReindexManager(amo.tests.TestCase):
def test_flag_reindexing(self):
assert Reindexing.objects.filter(site='foo').count() == 0
# Flagging for the first time.
res = Reindexing.objects._f... | muffinresearch/addons-server | lib/es/tests/test_models.py | Python | bsd-3-clause | 3,449 |
"""
HttpError Spider Middleware
See documentation in docs/topics/spider-middleware.rst
"""
import logging
from scrapy.exceptions import IgnoreRequest
logger = logging.getLogger(__name__)
class HttpError(IgnoreRequest):
"""A non-200 response was filtered"""
def __init__(self, response, *args, **kwargs):
... | rolando-contrib/scrapy | scrapy/spidermiddlewares/httperror.py | Python | bsd-3-clause | 1,921 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import models, api
class ir_translation(models.Model):
_inherit = 'ir.translation'
@api.model
def _get_terms_mapping(self, field, records):
if self._context.get('edit_translations'):
... | minhphung171093/GreenERP | openerp/addons/web_editor/models/ir_translation.py | Python | gpl-3.0 | 578 |
# coding: utf-8
from sqlalchemy.testing import eq_, assert_raises, assert_raises_message, \
config, is_, is_not_, le_
import re
from sqlalchemy.testing.util import picklers
from sqlalchemy.interfaces import ConnectionProxy
from sqlalchemy import MetaData, Integer, String, INT, VARCHAR, func, \
bindparam, selec... | wfxiang08/sqlalchemy | test/engine/test_execute.py | Python | mit | 92,658 |
from __future__ import unicode_literals
from .. import Provider as PhoneNumberProvider
class Provider(PhoneNumberProvider):
formats = (
'(351) 91# ### ###',
'(351) 92# ### ###',
'(351) 93# ### ###',
'(351) 96# ### ###',
'(351) 2## ### ###',
'(351) 91#######',
... | deanishe/alfred-fakeum | src/libs/faker/providers/phone_number/pt_PT/__init__.py | Python | mit | 1,053 |
# Copyright 2019 Fortinet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the... | anryko/ansible | test/units/modules/network/fortios/test_fortios_log_custom_field.py | Python | gpl-3.0 | 7,817 |
# 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... | benoitsteiner/tensorflow-xsmm | tensorflow/contrib/rnn/python/kernel_tests/lstm_ops_test.py | Python | apache-2.0 | 21,832 |
# Copyright 2012 the V8 project authors. 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 list of conditi... | guorendong/iridium-browser-ubuntu | v8/tools/testrunner/objects/testcase.py | Python | bsd-3-clause | 3,600 |
from unittest import TestCase
from django.template import Context, Template, VariableNode
from django.test import override_settings
class NodelistTest(TestCase):
def test_for(self):
template = Template('{% for i in 1 %}{{ a }}{% endfor %}')
vars = template.nodelist.get_nodes_by_type(VariableNode... | oscaro/django | tests/template_tests/test_nodelist.py | Python | bsd-3-clause | 2,315 |
import re, inspect, textwrap, pydoc
import sphinx
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
class SphinxDocString(NumpyDocString):
def __init__(self, docstring, config=None):
config = {} if config is None else config
self.use_plots = config.get('use_plots', False)
NumpyDoc... | cigroup-ol/metaopt | docs/_extensions/numpy_ext/docscrape_sphinx.py | Python | bsd-3-clause | 7,924 |
from badger.models import Badge
from badger.views import BadgesListView
class KBadgesListView(BadgesListView):
def get_queryset(self):
qs = Badge.objects.order_by('-created')
return qs
badges_list = KBadgesListView.as_view()
| mythmon/kitsune | kitsune/kbadge/views.py | Python | bsd-3-clause | 248 |
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
class WebsiteTheme(Document):
def validate(self):
self.validate_if_customizabl... | indictranstech/frappe | frappe/website/doctype/website_theme/website_theme.py | Python | mit | 2,827 |
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# ------------------------------------------------------... | crossroadchurch/paul | tests/interfaces/openlp_plugins/songs/forms/__init__.py | Python | gpl-2.0 | 1,544 |
import os
import sys
from optparse import OptionParser, NO_DEFAULT
import imp
import django
from google.appengine._internal.django.core.management.base import BaseCommand, CommandError, handle_default_options
from google.appengine._internal.django.utils.importlib import import_module
# For backwards compatibility: ge... | ychen820/microblog | y/google-cloud-sdk/platform/google_appengine/google/appengine/_internal/django/core/management/__init__.py | Python | bsd-3-clause | 17,576 |
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Softwa... | yuyuyu101/VirtualBox-NetBSD | src/libs/xpcom18a4/python/tools/tracer_demo.py | Python | gpl-2.0 | 4,360 |
"""
sentry.rules.actions.notify_event
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: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
from sentry.plugins import plugins
from sentry.rules.actions.base import EventAct... | felixbuenemann/sentry | src/sentry/rules/actions/notify_event.py | Python | bsd-3-clause | 1,345 |
# -*- 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 ... | Jgarcia-IAS/localizacion | openerp/addons-extra/odoo-pruebas/odoo-server/addons/email_template/email_template.py | Python | agpl-3.0 | 30,293 |
from __future__ import unicode_literals
import datetime
import os
import subprocess
from django.utils.lru_cache import lru_cache
def get_version(version=None):
"Returns a PEP 386-compliant version number from VERSION."
version = get_complete_version(version)
# Now build the two parts of the version num... | simbha/mAngE-Gin | lib/django/utils/version.py | Python | mit | 2,279 |
'''
Python class on writing reusable code
'''
def func2():
'''Simple test function'''
print "Simple"
if __name__ == "__main__":
print "Main program - simple"
| cb1234/pynet-test | pyth_ansibel/class9/exercise1/mytest/simple.py | Python | apache-2.0 | 171 |
from django import forms
from wagtail.wagtaildocs.models import Document
class DocumentForm(forms.ModelForm):
required_css_class = "required"
class Meta:
model = Document
fields = ('title', 'file', 'tags')
widgets = {
'file': forms.FileInput()
}
| mephizzle/wagtail | wagtail/wagtaildocs/forms.py | Python | bsd-3-clause | 302 |
#!/usr/bin/env python
# Copyright 2010-2014 RethinkDB, all rights reserved.
import sys
"""This script is used to generate the RDB_MAKE_SERIALIZABLE_*() and
RDB_MAKE_ME_SERIALIZABLE_*() macro definitions. Because there are so
many variations, and because they are so similar, it's easier to just
have a Python script to ... | pap/rethinkdb | scripts/generate_serialize_macros.py | Python | agpl-3.0 | 9,043 |
"""Collection of helper methods.
All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.vacuum import (
ATTR_FAN_SPEED,
ATTR_PARAMS,
DOMAIN,
SERVICE_CLEAN_SPOT,
SERVICE_LOCATE,
SERVICE_PAUSE,
... | jawilson/home-assistant | tests/components/vacuum/common.py | Python | apache-2.0 | 6,031 |
from django import http
from django.utils.translation import check_for_language, activate, to_locale, get_language
from django.utils.text import javascript_quote
from django.conf import settings
import os
import gettext as gettext_module
def set_language(request):
"""
Redirect to a given url while setting the ... | Shrews/PyGerrit | webapp/django/views/i18n.py | Python | apache-2.0 | 6,587 |
# tests for reconstruction code
| StongeEtienne/dipy | dipy/reconst/tests/__init__.py | Python | bsd-3-clause | 32 |
from tests.package.test_perl import TestPerlBase
class TestPerlDBDmysql(TestPerlBase):
"""
package:
DBD-mysql XS
direct dependencies:
DBI XS
"""
config = TestPerlBase.config + \
"""
BR2_PACKAGE_PERL=y
BR2_PACKAGE_PERL_DBD_MYSQL=y
"""
def te... | masahir0y/buildroot-yamada | support/testing/tests/package/test_perl_dbd_mysql.py | Python | gpl-2.0 | 426 |
"""
Global Django exception and warning classes.
"""
class DjangoRuntimeWarning(RuntimeWarning):
pass
class ObjectDoesNotExist(Exception):
"The requested object does not exist"
silent_variable_failure = True
class MultipleObjectsReturned(Exception):
"The query returned multiple objects when only one w... | ychen820/microblog | y/google-cloud-sdk/platform/google_appengine/lib/django-1.3/django/core/exceptions.py | Python | bsd-3-clause | 2,767 |
import frappe
def execute():
frappe.reload_doc("core", "doctype", "todo")
try:
frappe.db.sql("""update tabToDo set status = if(ifnull(checked,0)=0, 'Open', 'Closed')""")
except:
pass
| geo-poland/frappe | frappe/patches/v4_0/set_todo_checked_as_closed.py | Python | mit | 191 |
import unittest
from openerp.tools import misc
class test_countingstream(unittest.TestCase):
def test_empty_stream(self):
s = misc.CountingStream(iter([]))
self.assertEqual(s.index, -1)
self.assertIsNone(next(s, None))
self.assertEqual(s.index, 0)
def test_single(self):
... | vileopratama/vitech | src/openerp/addons/base/tests/test_misc.py | Python | mit | 1,108 |
# 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... | lukeiwanski/tensorflow | tensorflow/contrib/learn/python/learn/__init__.py | Python | apache-2.0 | 2,715 |
"""Tests for the Google Translate integration."""
| nkgilley/home-assistant | tests/components/google_translate/__init__.py | Python | apache-2.0 | 50 |
#
# (c) 2020 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
# (at your option) any later version.
#
# Ansible is d... | azaghal/ansible | test/units/plugins/connection/test_local.py | Python | gpl-3.0 | 1,355 |
class C:
''' <caret>
''' | asedunov/intellij-community | python/testData/editing/spaceDocStringStubInClass.after.py | Python | apache-2.0 | 28 |
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
import hmac
from cryptography.hazmat.bindings._constant_time import lib
... | ARMmbed/yotta_osx_installer | workspace/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py | Python | apache-2.0 | 798 |
from __future__ import division, absolute_import, print_function
from numpy.core.machar import MachAr
import numpy.core.numerictypes as ntypes
from numpy import errstate, array
from numpy.testing import TestCase, run_module_suite
class TestMachAr(TestCase):
def _run_machar_highprec(self):
# Instantiate Ma... | mbayon/TFG-MachineLearning | venv/lib/python3.6/site-packages/numpy/core/tests/test_machar.py | Python | mit | 1,014 |
# -*- test-case-name: twisted.test.test_logfile -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
A rotating, browsable log file.
"""
# System Imports
import os, glob, time, stat
from twisted.python import threadable
class BaseLogFile:
"""
The base class for a log file that ... | skycucumber/Messaging-Gateway | webapp/venv/lib/python2.7/site-packages/twisted/python/logfile.py | Python | gpl-2.0 | 9,711 |
from __future__ import unicode_literals
from threading import local
from django.utils import six
from django.utils.encoding import force_text, iri_to_uri
from django.utils.functional import lazy
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import override
from .e... | KrzysztofStachanczyk/Sensors-WWW-website | www/env/lib/python2.7/site-packages/django/urls/base.py | Python | gpl-3.0 | 5,668 |
"""
Pure SciPy implementation of Locally Optimal Block Preconditioned Conjugate
Gradient Method (LOBPCG), see
http://www-math.cudenver.edu/~aknyazev/software/BLOPEX/
License: BSD
Authors: Robert Cimrman, Andrew Knyazev
Examples in tests directory contributed by Nils Wagner.
"""
from __future__ import division, prin... | jlcarmic/producthunt_simulator | venv/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py | Python | mit | 19,348 |
# Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
'''commands to sign and verify changesets'''
import os, tempfile, binascii
from mercurial import util, comman... | iaddict/mercurial.rb | vendor/mercurial/hgext/gpg.py | Python | mit | 9,365 |
# 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.
#
# Ansible is distributed in the hope that ... | tsdmgz/ansible | lib/ansible/module_utils/facts/hardware/darwin.py | Python | gpl-3.0 | 3,527 |
"""
HTML Widget classes
"""
from __future__ import absolute_import, unicode_literals
import copy
import datetime
from itertools import chain
try:
from urllib.parse import urljoin
except ImportError: # Python 2
from urlparse import urljoin
from django.conf import settings
from django.forms.util import fla... | ychen820/microblog | y/google-cloud-sdk/platform/google_appengine/lib/django-1.5/django/forms/widgets.py | Python | bsd-3-clause | 35,106 |
from __future__ import unicode_literals
import os.path
from django.utils._os import upath
TEST_ROOT = os.path.dirname(upath(__file__))
TESTFILES_PATH = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test')
TEST_SETTINGS = {
'DEBUG': True,
'MEDIA_URL': '/media/',
'STATIC_URL': '/static/',
'MEDIA... | DONIKAN/django | tests/staticfiles_tests/settings.py | Python | bsd-3-clause | 1,039 |
"""Facility to use the Expat parser to load a minidom instance
from a string or file.
This avoids all the overhead of SAX and pulldom to gain performance.
"""
# Warning!
#
# This module is tightly bound to the implementation details of the
# minidom DOM and can't be used with other DOM implementations. This
# is due... | huran2014/huran.github.io | wot_gateway/usr/lib/python2.7/xml/dom/expatbuilder.py | Python | gpl-2.0 | 36,382 |
# -*- coding: utf-8 -*-
"""
jinja2.debug
~~~~~~~~~~~~
Implements the debug interface for Jinja. This module does some pretty
ugly stuff with the Python traceback system in order to achieve tracebacks
with correct line numbers, locals and contents.
:copyright: (c) 2010 by the Jinja Team.
:... | Apreche/Presentoh | utils/jinja2/debug.py | Python | mit | 9,931 |
#
# gdb helper commands and functions for Linux kernel debugging
#
# per-cpu tools
#
# Copyright (c) Siemens AG, 2011-2013
#
# Authors:
# Jan Kiszka <jan.kiszka@siemens.com>
#
# This work is licensed under the terms of the GNU GPL version 2.
#
import gdb
from linux import tasks, utils
MAX_CPUS = 4096
def get_cu... | GuillaumeSeren/linux | scripts/gdb/linux/cpus.py | Python | gpl-2.0 | 4,543 |
import serial
from time import sleep
import base64
import sys
def readSerial():
while True:
response = ser.readline();
return response
# main
ser = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=3)
ser.isOpen()
# Wait UART Listener VM to be done.
while(1):
message = readSerial()
i... | prplfoundation/prpl-hypervisor | bin/board-control.py | Python | isc | 1,093 |
# -*- coding: utf-8 -*-
#
# tree.py
#
# (c) D.C.-G. 2014
#
# Tree widget for albow
#
from albow.widget import Widget
from albow.menu import Menu
from albow.fields import IntField, FloatField, TextFieldWrapped
from albow.controls import CheckBox, AttrRef, Label, Button
from albow.dialogs import ask, alert, input_text_bu... | violine1101/MCEdit-Unified | albow/tree.py | Python | isc | 20,371 |
#!/usr/bin/python3
"""
n0run.py -- a unit test runner.
n0run runs 0unit based tests programs and then does wierd things far beyond
the power of 0unit. We use n0run when we want to make sure that things fail
when and "how" they are supposed to, even if the "how" means the error
propagates all the way to the ... | adrianratnapala/elm0 | n0run.py | Python | isc | 10,558 |
#!/usr/bin/env python
r'''
Display
-------
.. autosummary::
:toctree: generated/
display
display_multi
'''
from collections import OrderedDict
import json
import re
import six
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredText
import mir_eval.display
fro... | marl/jams | jams/display.py | Python | isc | 6,670 |
# The docs say the processing time is less than 20 milliseconds
#PROCESSING_TIME = 0.015
PROCESSING_TIME = 0.010
INTERVAL_SCALE = 0.95
# Number of degrees for a small angle... if the angle is smaller than this then
# the rover won't try to turn, to help keep the path straight
SMALL_ANGLE = 7.0
# Ensure that the rove... | eklitzke/icfp08 | src/constants.py | Python | isc | 491 |
# orm/descriptor_props.py
# Copyright (C) 2005-2022 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: https://www.opensource.org/licenses/mit-license.php
"""Descriptor properties are more "auxiliary" properties
that exist as conf... | sqlalchemy/sqlalchemy | lib/sqlalchemy/orm/descriptor_props.py | Python | mit | 25,542 |
cypher = input()
per = "PER"
count = 0
for i in range(len(cypher)):
if cypher[i] != per[i%3]:
count +=1
print(count) | rvrheenen/OpenKattis | Python/conundrum/conundrum.py | Python | mit | 128 |
"""empty message
Revision ID: 251447ab2060
Revises: 53ac0b4e8891
Create Date: 2018-09-19 09:49:05.552597
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '251447ab2060'
down_revision = '53ac0b4e8891'
branch_labels = None
depends_on = None
def upgrade():
# ... | gems-uff/labsys | migrations/versions/2018-09-19_09:49:05__251447ab2060.py | Python | mit | 680 |
import asyncio
from pulsar.apps import rpc, wsgi, ws
from wsrpc import WSRPC
class EchoRPC(WSRPC):
def rpc_echo(self, websocket, blob):
for x in range(10):
yield from asyncio.sleep(0.5)
websocket.write(blob)
websocket.write_close()
def server():
wm = ws.WebSocket('... | davebshow/zrpc | echo_server.py | Python | mit | 470 |
#!/usr/bin/python2
#-*- coding: utf-8 -*-
#
# This file is released under the MIT License.
#
# (C) Copyright 2012 Alessio Colucci
# 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
# res... | Alexey95/physpy | physpy/__init__.py | Python | mit | 1,808 |
class ImageClass():
"Stores the paths to images for a given class"
def __init__(self, name, image_paths):
self.name = name
self.image_paths = image_paths
def __str__(self):
return self.name + ', ' + str(len(self.image_paths)) + ' images'
def __len__(self):
return le... | liuzz1983/open_vision | openvision/datasets/utils.py | Python | mit | 1,945 |
var.index('André')
index(var, 'André')
#https://pt.stackoverflow.com/q/199737/101
| maniero/SOpt | Python/Function/Sugar.py | Python | mit | 86 |
import hashlib
import sys
import datetime
class EmailObject:
def __init__(self, sender, date, subject, body):
self.sender = sender
self.date = datetime.datetime.strptime(date[5:25], '%d %b %Y %H:%M:%S') #TODO: FIX THIS CODE TO BE MORE ROBUST
self.body = body
self.subject = subject
... | liamneath1/SUMOWaferBackend | PythonBackend/EmailObject.py | Python | mit | 1,333 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# The MIT License (MIT)
#
# Copyright (c) 2014 Bartosz Janda
#
# 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 w... | bartoszj/Mallet | mallet/loader.py | Python | mit | 21,220 |
from django.db import models
from core.models.base import Base
class SiteMessage(Base):
message = models.TextField()
class Meta:
app_label = "core"
db_table = 'site_message'
def __str__(self):
return self.message
| slohr/paperlims | paperlims/core/models/site_message.py | Python | mit | 236 |
from . import FixtureTest
class TrolleybusIsABus(FixtureTest):
def test_industrial_street(self):
self.load_fixtures([
'http://www.openstreetmap.org/way/397268717',
'http://www.openstreetmap.org/relation/2996736',
], clip=self.tile_bbox(16, 10484, 25339))
self.asser... | mapzen/vector-datasource | integration-test/629-trolleybus-is-a-bus.py | Python | mit | 1,163 |
from api.lib.testutils import BaseTestCase
import api.companies.unittest
class TestUpdateCompany(BaseTestCase):
def test_update_company(self):
resp = self.app.put('/companies/exponential',
data='{"name": "Exponential.io", "city": "Menlo Park"}',
he... | girisagar46/flask_restipy | api/companies/unittest/update_company_test.py | Python | mit | 558 |
"""
Python Interchangeable Virtual Instrument Library
Copyright (c) 2012-2016 Alex Forencich
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... | Diti24/python-ivi | ivi/lecroy/lecroyWR204MXIA.py | Python | mit | 1,653 |
class Solution(object):
def palindromePartition(self, s, k):
"""
:type s: str
:type k: int
:rtype: int
"""
palin_price = []
for _ in s:
# palin_price[begin][end]: Number of characters to change s[begin:end+1] to palindrome
palin_price.a... | daicang/Leetcode-solutions | 5278-palindrome-partitioning-iii.py | Python | mit | 1,998 |
#!/usr/bin/env python
import sys, os, re, tarfile, json
FILES = {
'africa', 'antarctica', 'asia', 'australasia',
'europe', 'northamerica', 'southamerica',
}
WS_SPLIT = re.compile("[ \t]+")
def lines(fn):
with tarfile.open(fn, 'r:*') as tar:
for info in tar:
if not info.isfile() or info.name not in FILE... | djc/awmy | zones.py | Python | mit | 1,974 |
import sys
from io import BytesIO
from whoops.httplib.http_server import HttpServer
from whoops import ioloop
class WSGIServer(HttpServer):
def __init__(self, ioloop, address):
super(WSGIServer, self).__init__(ioloop, address)
self.app = None
self.environ = None
self.result = Non... | jasonlvhit/whoops | whoops/wsgilib/wsgi_server.py | Python | mit | 3,279 |
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
from creds import *
from requests import Request
import requests
import json
import re
import tempfile
import redis
import uuid
from pydub import AudioSegment
def gettoken(uid):
red = redis.from_url(redis_url)
token = red.get(uid+"-access... | blackshroud/alexaweb | app.py | Python | mit | 5,569 |
#!/usr/bin/env python
# encoding: utf-8
import json
decoder = json.JSONDecoder()
def get_decoded_and_remainder(input_data):
obj, end = decoder.raw_decode(input_data)
remaining = input_data[end:]
return (obj, end, remaining)
encoded_object = '[{"a": "A", "c": 3.0, "b": [2, 4]}]'
extra_text = 'This text... | Akagi201/learning-python | json/json_mixed_data.py | Python | mit | 762 |
import os
import json
import datetime
from functools import reduce
from copy import deepcopy
from dataflow import config
def read_data(name):
"READ JSON DATA and return a dict"
with open(os.path.join(config.static_dir, 'scripts', name), 'r') as fl:
data= json.loads(fl.read())
return data
def wrap... | theSage21/dataflow | dataflow/scribe.py | Python | mit | 5,172 |
"""test the cli_builder module"""
import unittest
from control.cli_builder import builder, Argument
from control.exceptions import ControlException
class BuilderFormattingTests(unittest.TestCase):
"""
Tests to make sure that the builders correctly create newlines when they
should.
Tests to make sure... | PetroDE/control | control/tests/test_builder.py | Python | mit | 11,309 |
from typing import TYPE_CHECKING
import arrow
import requests
from io import BytesIO
from pyEchosign.utils.request_parameters import get_headers
from pyEchosign.utils.handle_response import check_error
if TYPE_CHECKING:
from .account import EchosignAccount
class LibraryDocument(object):
"""
Represents ... | JensAstrup/pyEchosign | pyEchosign/classes/library_document.py | Python | mit | 4,570 |
# -*- coding:utf-8 -*-
from urllib.parse import urlparse
from lxml import html
from lxml.html.clean import Cleaner
from .forms import FormWrapper
from .helpers import (
match_form,
filter_element
)
class HtmlParser:
""" Parses response content string to valid html using `lxml.html`
"""
def __i... | nuncjo/Delver | delver/parser.py | Python | mit | 2,824 |
from django.contrib.sites.shortcuts import get_current_site
from .models import Settings
def settings(request):
"""A context processor which provide current site ``Settings`` in ``settings`` template variable
Parameters
----------
request : HttpRequest
A django standard request object
"""... | watchdogpolska/watchdog-kj-kultura | watchdog_kj_kultura/main/context_processors.py | Python | mit | 399 |
# -*- coding: utf-8 -*-
"""
Created on Wed May 27 20:06:01 2015
@author: Thomas
"""
# Python standard library imports
import csv
SOLAR_CSV = "C:\Users\Thomas\Documents\GitHub\ProgProject\PVdata\SolarRadiation\solar_by_zip.csv"
OUTPUT_CSV = "C:\Users\Thomas\Documents\GitHub\ProgProject\PVdata\SolarRadiation\solar_by_... | Thomasvdw/ProgProject | Data/zipcode/zip_to_county_incts.py | Python | mit | 1,853 |
import galaxy.model
from galaxy.model.orm import *
from base.twilltestcase import TwillTestCase
class TestMetadataEdit( TwillTestCase ):
def test_00_metadata_edit( self ):
"""test_metadata_edit: Testing metadata editing"""
self.logout()
self.login( email='test@bx.psu.edu' )
self.ne... | dbcls/dbcls-galaxy | test/functional/test_metadata_editing.py | Python | mit | 2,489 |
import os
import pymysql
pymysql.install_as_MySQLdb()
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
MAIL_SERVER = 'smtp.163.com'
MAIL_PORT = 25
MAIL_USE_TLS = True
MAIL... | penglee87/flaskweb | config.py | Python | mit | 1,488 |
#!/usr/bin/env python
"""Provide command line interface to easygv."""
# Imports
import logzero
from logzero import logger as log
import os
from pathlib import Path
import appdirs
from munch import Munch
import click
import graphviz as gv
from easygv.cli import config as _config
from easygv import easygv
# Meta... | xguse/easygv | easygv/cli/__init__.py | Python | mit | 5,459 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import json
import os
import random as _random
import sys
import traceback
from getopt import getopt, GetoptError
from multiprocessing import Process
from os import environ
from wsgiref.simple_server import make_server
import requests as _requests
from json... | dcchivian/kb_gblocks | lib/kb_gblocks/kb_gblocksServer.py | Python | mit | 23,262 |
class MoveOperations:
"""Specifies criteria for how to move files."""
none = 0
overwrite = 1
| vgrem/Office365-REST-Python-Client | office365/sharepoint/files/move_operations.py | Python | mit | 105 |
import unittest
import os
from test.aiml_tests.client import TestClient
from programy.config.brain import BrainFileConfiguration
class BasicTestClient(TestClient):
def __init__(self):
TestClient.__init__(self)
def load_configuration(self, arguments):
super(BasicTestClient, self).load_configur... | dkamotsky/program-y | src/test/aiml_tests/person_tests/test_person_aiml.py | Python | mit | 904 |
"""
usage: manage.py [--help] <command> [<args>...]
The most commonly used git commands are:
syncdb Creates db models
dropdb Drop db models
"""
from database import init_db
from docopt import docopt
def main():
args = docopt(__doc__,
options_first=True)
if args['<command>'] == 'syncdb':
... | RevelSystems/revel-bootstrap | manage.py | Python | mit | 476 |
"""
example microbial protein:
https://www.wikidata.org/wiki/Q22291171
example yeast protein:
https://www.wikidata.org/wiki/Q27553062
Data source: Quickgo mongo
"""
import argparse
import json
import os
import traceback
from collections import defaultdict
from datetime import datetime
from functools import partial
fr... | SuLab/scheduled-bots | scheduled_bots/geneprotein/GOBot.py | Python | mit | 14,190 |
from multicorn import ForeignDataWrapper
from cassandra_provider import CassandraProvider
from properties import ISDEBUG
import properties
import schema_importer
import time
class CassandraFDW(ForeignDataWrapper):
def __init__(self, options, columns):
super(CassandraFDW, self).__init__(options, columns)
... | rankactive/cassandra-fdw | cassandra-fdw/__init__.py | Python | mit | 4,389 |
import pyb
from struct import unpack as unp
# BMP180 default address
BMP180_I2CADDR = 0x77
# Operating Modes
BMP180_ULTRALOWPOWER = 0
BMP180_STANDARD = 1
BMP180_HIGHRES = 2
BMP180_ULTRAHIGHRES = 3
# BMP180 Registers
BMP180_CAL_AC1 = 0xAA
BMP180_CAL_AC2 = 0xAC
BMP180_... | pymagic-org/pymagic_driver | bmp180.py | Python | mit | 5,278 |
from rest_framework import serializers
from .models import User
from .models import Group
from .models import UserGroup
from .models import ChangeDetail
from .models import GroupChange
from .models import UserChange
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields... | mbuciora/eWallet | eWallet_app/serializers.py | Python | mit | 989 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.