prompt large_stringlengths 72 9.34k | completion large_stringlengths 0 7.61k |
|---|---|
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Return empty MAC to name dict. Overridden if DHCP server is set."""
self.mac2name = {} |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Return the name of the given device or None if we don't know."""
if self.mac2name is None:
self._generate_mac2name()
if self.mac2name is None:
# Generation of mac2name dictionary failed
return None
name = self.mac2name.get(device.upper(), None)
... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Ensure the information from the router is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init:
return False
_LOGGER.info("Checking hostapd")
if not self.hostapd:
hostapd = self.ubus.get_hostapd()
self.... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Implement the Ubus device scanning for the dnsmasq DHCP server."""
def __init__(self, config):
"""Initialize the scanner."""
super().__init__(config)
self.leasefile = None
def _generate_mac2name(self):
if self.leasefile is None:
if result := self.ubus.get_uci... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Initialize the scanner."""
super().__init__(config)
self.leasefile = None |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | if self.leasefile is None:
if result := self.ubus.get_uci_config("dhcp", "dnsmasq"):
values = result["values"].values()
self.leasefile = next(iter(values))["leasefile"]
else:
return
result = self.ubus.file_read(self.leasefile)
... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | """Implement the Ubus device scanning for the odhcp DHCP server."""
def _generate_mac2name(self):
if result := self.ubus.get_dhcp_method("ipv4leases"):
self.mac2name = {}
for device in result["device"].values():
for lease in device["leases"]:
... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | if result := self.ubus.get_dhcp_method("ipv4leases"):
self.mac2name = {}
for device in result["device"].values():
for lease in device["leases"]:
mac = lease["mac"] # mac = aabbccddeeff
# Convert it to expected format with colon
... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | scanner = DnsmasqUbusDeviceScanner(config[DOMAIN]) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | scanner = OdhcpdUbusDeviceScanner(config[DOMAIN]) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | scanner = UbusDeviceScanner(config[DOMAIN]) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | self._generate_mac2name() |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | return None |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | return False |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | hostapd = self.ubus.get_hostapd()
self.hostapd.extend(hostapd.keys()) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | results = results + 1
# Check for each device is authorized (valid wpa key)
for key in result["clients"].keys():
device = result["clients"][key]
if device["authorized"]:
self.last_results.append(key) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | self.last_results.append(key) |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | if result := self.ubus.get_uci_config("dhcp", "dnsmasq"):
values = result["values"].values()
self.leasefile = next(iter(values))["leasefile"]
else:
return |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | values = result["values"].values()
self.leasefile = next(iter(values))["leasefile"] |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | return |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | self.mac2name = {}
for line in result["data"].splitlines():
hosts = line.split(" ")
self.mac2name[hosts[1].upper()] = hosts[3] |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | return |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | self.mac2name = {}
for device in result["device"].values():
for lease in device["leases"]:
mac = lease["mac"] # mac = aabbccddeeff
# Convert it to expected format with colon
mac = ":".join(mac[i : i + 2] for i in range(... |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | return |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | get_scanner |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | _refresh_on_access_denied |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | decorator |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | __init__ |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | scan_devices |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | _generate_mac2name |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | get_device_name |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | _update_info |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | __init__ |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | _generate_mac2name |
<|file_name|>device_tracker.py<|end_file_name|><|fim▁begin|>"""Support for OpenWRT (ubus) routers."""
import logging
import re
from openwrt.ubus import Ubus
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
DeviceScanner,
)
f... | _generate_mac2name |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | return os.path.dirname(scrapy_path) + os.pathsep + os.environ.get('PYTHONPATH', '')
|
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """Asserts the current environment is suitable for running AWS testsi.
Raises SkipTest with the reason if it's not.
"""
skip_if_no_boto()
if 'AWS_ACCESS_KEY_ID' not in os.environ:
raise SkipTest("AWS keys not found") |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | if 'GCS_PROJECT_ID' not in os.environ:
raise SkipTest("GCS_PROJECT_ID not found") |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | try:
is_botocore()
except NotConfigured as e:
raise SkipTest(e) |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """ Get content from s3 key, and delete key afterwards.
"""
if is_botocore():
import botocore.session
session = botocore.session.get_session()
client = session.create_client('s3')
key = client.get_object(Bucket=bucket, Key=path)
content = key['Body'].read()
cl... |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | from google.cloud import storage
client = storage.Client(project=os.environ.get('GCS_PROJECT_ID'))
bucket = client.get_bucket(bucket)
blob = bucket.get_blob(path)
content = blob.download_as_string()
bucket.delete_blob(path)
return content, blob |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """Return an unconfigured Crawler object. If settings_dict is given, it
will be used to populate the crawler settings with a project level
priority.
"""
from scrapy.crawler import CrawlerRunner
from scrapy.spiders import Spider
runner = CrawlerRunner(settings_dict)
return runner.create_... |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """Return a PYTHONPATH suitable to use in processes so that they find this
installation of Scrapy"""
scrapy_path = import_module('scrapy').__path__[0]
return os.path.dirname(scrapy_path) + os.pathsep + os.environ.get('PYTHONPATH', '') |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """Return a OS environment dict suitable to fork processes that need to import
this installation of Scrapy, instead of a system installed one.
"""
env = os.environ.copy()
env['PYTHONPATH'] = get_pythonpath()
return env |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | """Asserts text1 and text2 have the same lines, ignoring differences in
line endings between platforms
"""
testcase.assertEqual(text1.splitlines(), text2.splitlines(), msg) |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | raise SkipTest("AWS keys not found") |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | raise SkipTest("GCS_PROJECT_ID not found") |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | import botocore.session
session = botocore.session.get_session()
client = session.create_client('s3')
key = client.get_object(Bucket=bucket, Key=path)
content = key['Body'].read()
client.delete_object(Bucket=bucket, Key=path) |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | import boto
# assuming boto=2.2.2
bucket = boto.connect_s3().get_bucket(bucket, validate=False)
key = bucket.get_key(path)
content = key.get_contents_as_string()
bucket.delete_key(path) |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | assert_aws_environ |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | assert_gcs_environ |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | skip_if_no_boto |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | get_s3_content_and_delete |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | get_gcs_content_and_delete |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | get_crawler |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | get_pythonpath |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | get_testenv |
<|file_name|>test.py<|end_file_name|><|fim▁begin|>"""
This module contains some assorted functions used in tests
"""
from __future__ import absolute_import
import os
from importlib import import_module
from twisted.trial.unittest import SkipTest
from scrapy.exceptions import NotConfigured
from scrapy.utils.boto impo... | assert_samelines |
<|file_name|>constants.py<|end_file_name|><|fim▁begin|>import math as mth
import numpy as np
#----------------------
# J Matthews, 21/02
# This is a file containing useful constants for python coding
#
# Units in CGS unless stated
#
#----------------------
#H=6.62606957E-27
HEV=4.13620e-15
#C=29979245800.0
#BOLTZMAN... | |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | serializer = ConditionExportSerializer(self.get_queryset(), many=True)
xml = ConditionRenderer().render(serializer.data)
return XMLResponse(xml, name='conditions')
|
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | permission_classes = (HasModelPermission, )
queryset = Condition.objects.select_related('source', 'target_option') \
.prefetch_related('optionsets', 'questionsets', 'questions', 'tasks')
serializer_class = ConditionSerializer
filter_backends = (DjangoFilterBackend,)
... |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | queryset = Condition.objects.select_related('source', 'target_option')
serializer = ConditionIndexSerializer(queryset, many=True)
return Response(serializer.data) |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | serializer = ConditionExportSerializer(self.get_queryset(), many=True)
xml = ConditionRenderer().render(serializer.data)
return XMLResponse(xml, name='conditions') |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | serializer = ConditionExportSerializer(self.get_object())
xml = ConditionRenderer().render([serializer.data])
return XMLResponse(xml, name=self.get_object().key) |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | permission_classes = (IsAuthenticated, )
queryset = Condition.RELATION_CHOICES |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | index |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | export |
<|file_name|>viewsets.py<|end_file_name|><|fim▁begin|>from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rdmo... | detail_export |
<|file_name|>line_displaced.py<|end_file_name|><|fim▁begin|>from chiplotle.geometry.shapes.path import path
from chiplotle.geometry.transforms.perpendicular_displace \
import perpendicular_displace
def line_displaced(start_coord, end_coord, displacements):
'''Returns a Path defined as a line spanning points `s... |
if __name__ == '__main__':
from chiplotle import *
import math |
<|file_name|>line_displaced.py<|end_file_name|><|fim▁begin|>from chiplotle.geometry.shapes.path import path
from chiplotle.geometry.transforms.perpendicular_displace \
import perpendicular_displace
def line_displaced(start_coord, end_coord, displacements):
<|fim_middle|>
if __name__ == '__main__':
from ... | '''Returns a Path defined as a line spanning points `start_coord` and
`end_coord`, displaced by scalars `displacements`.
The number of points in the path is determined by the lenght of
`displacements`.
'''
p = path([start_coord, end_coord])
perpendicular_displace(p, displacements)
return... |
<|file_name|>line_displaced.py<|end_file_name|><|fim▁begin|>from chiplotle.geometry.shapes.path import path
from chiplotle.geometry.transforms.perpendicular_displace \
import perpendicular_displace
def line_displaced(start_coord, end_coord, displacements):
'''Returns a Path defined as a line spanning points `s... | from chiplotle import *
import math
disp = [math.sin(i**0.7 / 3.14159 * 2) * 100 for i in range(200)]
line = line_displaced(Coordinate(0, 0), Coordinate(1000, 1000), disp)
io.view(line) |
<|file_name|>line_displaced.py<|end_file_name|><|fim▁begin|>from chiplotle.geometry.shapes.path import path
from chiplotle.geometry.transforms.perpendicular_displace \
import perpendicular_displace
def <|fim_middle|>(start_coord, end_coord, displacements):
'''Returns a Path defined as a line spanning points `s... | line_displaced |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>from setuptools import setup, find_packages
setup(name='gelato.models',
version='0.1.2',
description='Gelato models',
namespace_packages=['gelato'],
long_description='',
author='',
author_email='',
license='',
url='',
... | packages=find_packages(exclude=['tests']), |
<|file_name|>update_tokens.py<|end_file_name|><|fim▁begin|>from optparse import make_option
<|fim▁hole|>from brambling.utils.payment import dwolla_update_tokens
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option(
'--days',
action='store',
... | from django.core.management.base import BaseCommand, CommandError
|
<|file_name|>update_tokens.py<|end_file_name|><|fim▁begin|>from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from brambling.utils.payment import dwolla_update_tokens
class Command(BaseCommand):
<|fim_middle|>
<|fim▁end|> | option_list = BaseCommand.option_list + (
make_option(
'--days',
action='store',
dest='days',
default=15,
help='Number of days ahead of time to update refresh tokens.'),
)
def handle(self, *args, **options):
try:
da... |
<|file_name|>update_tokens.py<|end_file_name|><|fim▁begin|>from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from brambling.utils.payment import dwolla_update_tokens
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option(
... | try:
days = int(options['days'])
except ValueError:
raise CommandError("Days must be an integer value.")
self.stdout.write("Updating dwolla tokens...")
self.stdout.flush()
count, test_count = dwolla_update_tokens(days)
self.stdout.write("Test token... |
<|file_name|>update_tokens.py<|end_file_name|><|fim▁begin|>from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from brambling.utils.payment import dwolla_update_tokens
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option(
... | handle |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | def __init__(self, group, data):
self.group = group
self.data = data
self.initWindow()
def initWindow(self):
self.dlg = gtk.Dialog()
self.dlg.set_title('Group Resize')
self.dlg.set_border_width(6)
self.dlg.vbox.pack_start(self.dialogContents(), fill=True,... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | self.group = group
self.data = data
self.initWindow() |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | self.dlg = gtk.Dialog()
self.dlg.set_title('Group Resize')
self.dlg.set_border_width(6)
self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5)
self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY)
self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RES... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | frame = gtk.Frame(label)
table = gtk.Table(rows=4, columns=2)
ignore = gtk.RadioButton(group=None, label="do not change")
ignore.show()
smallest = gtk.RadioButton(group=ignore, label="shrink to smallest")
smallest.show()
largest = gtk.RadioButton(group=ignore, lab... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | entrySpecify.set_sensitive(radioSpecify.get_active()) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | frame, self.widthOptions = self.dimensionsFrame('Width')
return frame |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | frame, self.heightOptions = self.dimensionsFrame('Height')
return frame |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | contents = gtk.VBox(spacing=5)
contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True)
contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True)
contents.show()
return contents |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | value = options['value'].get_text()
for opt in 'ignore', 'smallest', 'largest', 'specify':
if options[opt].get_active():
return (opt,value)
return ('ignore',value) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | if opt == 'specify':
return self.toFloat(value)
else:
values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ]
if opt == 'smallest':
return min(values)
else:
return max(values) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | for obj in self.group:
pos = obj.properties['obj_pos'].value
if obj.properties.has_key("elem_width"):
difference = value - obj.properties['elem_width'].value
handleLeft = obj.handles[3]
handleRight = obj.handles[4]
amount = ... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | for obj in self.group:
pos = obj.properties['obj_pos'].value
if obj.properties.has_key("elem_height"):
difference = value - obj.properties['elem_height'].value
handleTop = obj.handles[1]
handleBottom = obj.handles[6]
amount ... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | return locale.atof(valor) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | optWidth = self.getSelectedGroupOption(self.widthOptions)
optHeight = self.getSelectedGroupOption(self.heightOptions)
try:
if optWidth[0] != 'ignore':
width = self.getValue(optWidth[0], optWidth[1], 'elem_width')
self.adjustWidth(width)
if... |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | self.dlg.show() |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | self.dlg.hide() |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | return self.dlg.run() |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | diagram = dia.active_display().diagram
group = diagram.get_sorted_selected()
if len(group) > 0:
win = ResizeWindow(group, data)
win.show()
else:
dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | return (opt,value) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | return self.toFloat(value) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ]
if opt == 'smallest':
return min(values)
else:
return max(values) |
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|>#
# -*- coding: utf-8 -*-
# Dia Group Resize Plugin
# Copyright (c) 2015, Alexandre Machado <axmachado@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
# t... | return min(values) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.