hash
stringlengths
64
64
content
stringlengths
0
1.51M
f641d2e3a69d10bbc37cb5a473440b4145054f169a5254c392fa12edf132e6b1
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os from . import parse, from_table from .tree import VOTableFile, Table as VOTable from astropy.io import registry as io_registry from astropy.table import Table from astropy.table.column import BaseColumn from astropy.units import Quantity de...
a5b1a29a8504932be2cb1814596a2f3ec132d1f01a71efbec2c465e01d42a2e6
# Licensed under a 3-clause BSD style license - see LICENSE.rst # TODO: Test FITS parsing # STDLIB import io import re import sys import gzip import base64 import codecs import urllib.request import warnings # THIRD-PARTY import numpy as np from numpy import ma # LOCAL from astropy.io import fits from astropy import...
d509c8fd03e8cddca4d9a867ea6525992e996e96b0aa442ad364be88db5ac49a
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This file contains a contains the high-level functions to read a VOTable file. """ # STDLIB import io import os import sys import textwrap import warnings # LOCAL from . import exceptions from . import tree from astropy.utils.xml import iterparser f...
ddfd964d9f366aed3ba2c8db910dec45e14ed00245cc0ed3c0d8a8c42e1db4a1
# Licensed under a 3-clause BSD style license - see LICENSE.rst # -*- coding: utf-8 -*- """ .. _warnings: Warnings -------- .. note:: Most of the following warnings indicate violations of the VOTable specification. They should be reported to the authors of the tools that produced the VOTable file. T...
ac3be09491600673c291713f972fe2facf5ac847d05868e800a6717cda2c4e55
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ ``fitsheader`` is a command line script based on astropy.io.fits for printing the header(s) of one or more FITS file(s) to the standard output in a human- readable format. Example uses of fitsheader: 1. Print the header of all the HDUs of a .fits fil...
6a9acd02a0b335e9e427d205722042991d55ef749392e19a4540e2e93f8bf814
# Licensed under a 3-clause BSD style license - see PYFITS.rst import contextlib import csv import operator import os import re import sys import textwrap import warnings from contextlib import suppress import numpy as np from numpy import char as chararray from .base import DELAYED, _ValidHDU, ExtensionHDU # This ...
098acd4f73533f5cda790ee3fb3edf2d6ad0dbb2908071595492050948eb1111
# Licensed under a 3-clause BSD style license - see PYFITS.rst import datetime import os import sys import warnings from contextlib import suppress from inspect import signature, Parameter import numpy as np from astropy.io.fits import conf from astropy.io.fits.file import _File from astropy.io.fits.header import ...
2cb61d3e4eae1c7f7e4ebb19c2771426f217a189805fded12d47549cfd077b79
# Licensed under a 3-clause BSD style license - see PYFITS.rst import contextlib import copy import gc import pickle import re import pytest import numpy as np from numpy import char as chararray try: import objgraph HAVE_OBJGRAPH = True except ImportError: HAVE_OBJGRAPH = False from astropy.io import f...
298e95b40d6e09dc75328e24c4f38d1b41ae060908726ee29293fb7676228b55
# Licensed under a 3-clause BSD style license - see PYFITS.rst import glob import io import os import platform import sys import copy import subprocess import pytest import numpy as np from astropy.io.fits.verify import VerifyError from astropy.io import fits from astropy.tests.helper import raises, catch_warnings, ...
ade955b82baa257f95f83a28bd1db3e153d73b86ba102c3123706a589a7e1dc5
# Licensed under a 3-clause BSD style license - see PYFITS.rst import os import warnings import pytest import numpy as np from astropy.io import fits from astropy.table import Table from astropy.io.fits import printdiff from astropy.tests.helper import catch_warnings from . import FitsTestCase class TestConvenie...
9dc8a4ca846099518052fe3a438cf3ca709c6e933c874105e65f48efce90a3c4
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest import numpy as np from astropy.io.fits.column import Column from astropy.io.fits.diff import (FITSDiff, HeaderDiff, ImageDataDiff, TableDataDiff, HDUDiff) from astropy.io.fits.hdu import HDUList, PrimaryHDU, ImageHDU fro...
b518198a09e0e5aa8f2cc034689b05bf39680292345db8b279713880d82ee3c9
# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see PYFITS.rst import copy import warnings import collections from io import StringIO, BytesIO import pytest import numpy as np from astropy.io import fits from astropy.io.fits.verify import VerifyWarning from astropy.tests.helper import catch_...
b7126bcf506822b41a363de47b278fddbf0f76304eb8269df2bce33e422c0db8
# Licensed under a 3-clause BSD style license - see PYFITS.rst import gzip import bz2 import io import mmap import errno import os import pathlib import warnings import zipfile from unittest.mock import patch import pytest import numpy as np from . import FitsTestCase from astropy.io.fits.convenience import _getext...
805a6c25e95a6d7bdb5b252c62839c996b6e7233f7ca73906565d0d9b383e780
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest import numpy as np from . import FitsTestCase from astropy.io.fits.fitstime import GLOBAL_TIME_INFO, time_to_fits, is_time_column_keyword from astropy.coordinates import EarthLocation from astropy.io import fits from astropy.table import T...
f86e0b1a1ef2d299f60429aafea1d6a8751609fcfc593888fd03823d23761bf6
# Licensed under a 3-clause BSD style license - see PYFITS.rst import math import os import platform import re import time import warnings import pytest import numpy as np from numpy.testing import assert_equal from astropy.io import fits from astropy.tests.helper import catch_warnings, ignore_warnings from astropy...
82a4c1c9d0705e941010f61828a77949e0b5254b8d1551d1abcfe0ac40ac87b3
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import functools from io import BytesIO from textwrap import dedent import pytest import numpy as np from numpy import ma from astropy.table import Table, MaskedColumn from astropy.io import ascii from astropy.io.ascii.core import ParameterEr...
bdab091907bafbe583fa3959c9d23777743dd87fe48aaae5cd3c39b930c9991d
# Licensed under a 3-clause BSD style license - see LICENSE.rst # LOCAL from astropy.tests.helper import catch_warnings from astropy.io.votable import converters from astropy.io.votable import exceptions from astropy.io.votable import tree def test_reraise(): def fail(): raise RuntimeError("This failed"...
4560cb1309bac12a555c0c659aede22c44650c7579b2250ca12833a80f0bf622
# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is a set of regression tests for vo. """ # STDLIB import difflib import io import pathlib import sys import gzip from unittest import mock # THIRD-PARTY import pytest import numpy as np from numpy.testing import assert...
b199bee368a9f7d112105d689790c5743f2cdc7104180eb23d17a3bbf31b4d2f
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test the conversion to/from astropy.table """ import io import os import pathlib import pytest import numpy as np from astropy.config import set_temp_config, reload_config from astropy.utils.data import get_pkg_data_filename, get_pkg_data_fileobj fro...
bb23efbecb9ee2a2948f084a8db98089036850862431a3f8204a849bba7eb68c
# Licensed under a 3-clause BSD style license - see LICENSE.rst # LOCAL from astropy.io.votable import exceptions from astropy.io.votable import tree from astropy.tests.helper import raises @raises(exceptions.W07) def test_check_astroyear_fail(): config = {'verify': 'exception'} field = tree.Field(None, name=...
7b3a6a4542b454c826201384b264525440aa102289ee7e1a0ff1a24d5d176cb1
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io # THIRD-PARTY import numpy as np from numpy.testing import assert_array_equal # LOCAL from astropy.io.votable import converters from astropy.io.votable import exceptions from astropy.io.votable import tree from astropy.io.votable.table impo...
5953a99960049831b886a3084bd7450e6e553bf82f46f5f2822ee0d150692b45
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Contains a class to handle a validation result for a single VOTable file. """ # STDLIB from xml.parsers.expat import ExpatError import hashlib import os import shutil import socket import subprocess import warnings import pickle import urllib.request...
b8f72ad1e31450498fccf3758a5713d97059118c0f45f28ab50c5d00733b081b
# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest import numpy as np from numpy.testing import assert_allclose, assert_equal from astropy import units as u from astropy.time import Time, TimeDelta from astropy.tests.helper import assert_quantity_allclose from astrop...
171d5fd0c088056fa24dfdd26284779e7f8e3ed9df994cebc252e761a9498b23
import pytest from astropy import physical_constants, astronomical_constants import astropy.constants as const def test_version_match(): pversion = physical_constants.get() refpversion = const.h.__class__.__name__.lower() assert pversion == refpversion aversion = astronomical_constants.get() refa...
86866b8c96e44afb77daf8b12793aeb9460603e21943c20ba13e359a2130d270
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import pytest from astropy.constants import Constant from astropy.units import Quantity as Q def test_c(): from astropy.constants.codata2010 import c # c is an exactly defined constant, so it shouldn't be changing assert c.va...
4341f6d792bd85c68a703d1c774f08ad56477142f21f0689714c0ca28739a95e
import os import sys from distutils.sysconfig import get_python_lib from setuptools import find_packages, setup CURRENT_PYTHON = sys.version_info[:2] REQUIRED_PYTHON = (3, 5) # This check and everything above must remain compatible with Python 2.7. if CURRENT_PYTHON < REQUIRED_PYTHON: sys.stderr.write(""" ======...
c15b26a6fa245191f8e8738316cf3a160d3a06d31a8d566dd7c321dca923b713
#!/usr/bin/env python # # This python file contains utility scripts to manage Django translations. # It has to be run inside the django git root directory. # # The following commands are available: # # * update_catalogs: check for new strings in core and contrib catalogs, and # output how much string...
300f1f4d375bb33e7c0d957bfda0fb6ad78d8bd1ff758c286f11cc01ebf27fde
""" This module collects helper functions and classes that "span" multiple levels of MVC. In other words, these functions/classes introduce controlled coupling for convenience's sake. """ import warnings from django.http import ( Http404, HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect, ) from dj...
63785a3bb1f46523a1c104f76ab7fc4d68f8accc630c67482f5e2cc0b471a3ef
from django.utils.version import get_version VERSION = (2, 2, 0, 'alpha', 0) __version__ = get_version(VERSION) def setup(set_prefix=True): """ Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry. Set the thread-local...
f5ae53a35bd05ea7f6260fde87c9cbbc87341979838c45efe2313541912a0459
""" Invokes django-admin when the django module is run as a script. Example: python -m django check """ from django.core import management if __name__ == "__main__": management.execute_from_command_line()
ced3ddc90ae2bccd27e2e649550803646598cb1f46fabe22365bd7cc41a75e25
#!/usr/bin/env python import argparse import atexit import copy import os import shutil import subprocess import sys import tempfile import warnings import django from django.apps import apps from django.conf import settings from django.db import connection, connections from django.test import TestCase, TransactionTes...
004a3a216bfe0ea8189282f7c7ecbdc2602a8dc9f4464a7ac854d55ea29fdf72
"""This URLconf exists because Django expects ROOT_URLCONF to exist. URLs should be added within the test folders, and use TestCase.urls to set them. This helps the tests remain isolated. """ urlpatterns = []
1304896c1d81194a1ddd9c8d119a4b41cb11909c91b4496464856cc3a203ba24
# This is an example test settings file for use with the Django test suite. # # The 'sqlite3' backend requires only the ENGINE setting (an in- # memory database will be used). All other backends will require a # NAME and potentially authentication information. See the # following section in the docs for more informatio...
b81cfc18c6e633527f7a258353f301d3fd5b33b19c70145cd2d5f8c9a02d12aa
# Django documentation build configuration file, created by # sphinx-quickstart on Thu Mar 27 09:06:53 2008. # # 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 picklable (module imports are okay...
a8fdb4df33708daa255059d72cd6479ee067ec7373cb0f7f26438310244a65b7
"""Multi-consumer multi-producer dispatching mechanism Originally based on pydispatch (BSD) https://pypi.org/project/PyDispatcher/2.0.1/ See license.txt for original license. Heavily modified for Django's purposes. """ from django.dispatch.dispatcher import Signal, receiver # NOQA
efb1c122d49f1933f334e9db84ce2c30d12049ac25f72335196c78f1226baf46
import threading import weakref from django.utils.inspect import func_accepts_kwargs def _make_id(target): if hasattr(target, '__func__'): return (id(target.__self__), id(target.__func__)) return id(target) NONE_ID = _make_id(None) # A marker for caching NO_RECEIVERS = object() class Signal: ...
0c54d4bde05865f38328753f5cdf94269be6e155de83efeec53107e12b02ddf6
import sys import unittest from contextlib import contextmanager from django.test import LiveServerTestCase, tag from django.utils.module_loading import import_string from django.utils.text import capfirst class SeleniumTestCaseBase(type(LiveServerTestCase)): # List of browsers to dynamically create test classes...
e45ae6be006bc73668e5454b5bd1d9d621c130c85c9d770d2f9636c676aa54f0
"""Django Unit Test framework.""" from django.test.client import Client, RequestFactory from django.test.testcases import ( LiveServerTestCase, SimpleTestCase, TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessAnyDBFeature, skipUnlessDBFeature, ) from django.test.utils import ( ignore_warnings, mod...
58ca601dd653e59fb856cc8b9840364a84cb1eb974a8b428b579b17cdaccd447
import ctypes import itertools import logging import multiprocessing import os import pickle import textwrap import unittest from importlib import import_module from io import StringIO from django.core.management import call_command from django.db import connections from django.test import SimpleTestCase, TestCase fro...
fa284d512c8c0527d9c18375cd1b9a50b6021eef8a2f5be8d18a9f0b5f59b741
import json import mimetypes import os import re import sys from copy import copy from functools import partial from http import HTTPStatus from importlib import import_module from io import BytesIO from urllib.parse import unquote_to_bytes, urljoin, urlparse, urlsplit from django.conf import settings from django.core...
6b54ebc01369ef566c0d2bf3ce4413da26cae844c59900e2a0aa0fb2193570a7
import difflib import json import posixpath import sys import threading import unittest from collections import Counter from contextlib import contextmanager from copy import copy from functools import wraps from unittest.util import safe_repr from urllib.parse import ( parse_qsl, unquote, urlencode, urljoin, urlpa...
371f2f142bd232bfa79547fd0a894c299241c394e67da8e42dab72e1d8ce6c56
"""Compare two HTML documents.""" import re from html.parser import HTMLParser WHITESPACE = re.compile(r'\s+') def normalize_whitespace(string): return WHITESPACE.sub(' ', string) class Element: def __init__(self, name, attributes): self.name = name self.attributes = sorted(attributes) ...
3f4717c5177dec9741abcb2fdb7b98c02cab4b4f772df0dd51fa2165ef2d81be
import collections import logging import re import sys import time import warnings from contextlib import contextmanager from functools import wraps from io import StringIO from itertools import chain from types import SimpleNamespace from unittest import TestCase, skipIf, skipUnless from xml.dom.minidom import Node, p...
05094ed295d94ce75c6e1816d6024b735e965b643be70c7fdb085e1b990287d5
import os import threading import time import warnings from django.apps import apps from django.core.exceptions import ImproperlyConfigured from django.core.signals import setting_changed from django.db import connections, router from django.db.utils import ConnectionRouter from django.dispatch import Signal, receiver...
156c60fe798b3cd1aa5f048cc3442f66c28d42c895047ad2b0d7e000b217a90d
#!/usr/bin/env python from django.core import management if __name__ == "__main__": management.execute_from_command_line()
5b2f6aa4679c5991527f7f219de91c748a21dd0365d96530d881c3905fb2b066
import functools import sys import threading import warnings from collections import Counter, OrderedDict, defaultdict from functools import partial from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured from .config import AppConfig class Apps: """ A registry that stores the configura...
b74178c9c794e126f26cc79606fa6e13a46c19a10d9900956cd49d4ae5e210cb
from .config import AppConfig from .registry import apps __all__ = ['AppConfig', 'apps']
99ec968d72edd2a80f7ea335e0a19a5ac65a91b81afb0b875ecbb68241f243eb
import os from importlib import import_module from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import module_has_submodule MODELS_MODULE_NAME = 'models' class AppConfig: """Class representing a Django application and its configuration.""" def __init__(self, app_name,...
0c6740b860b4b756cc8eef62f81f69fe0a8f8112051ed2d74dd23134a5851acc
from django.views.generic.base import View __all__ = ['View']
475b52e394fcaf93fa5daf2e9b31fa45c3b8767848cc79e548a144a48a1ba47c
""" Views and functions for serving static files. These are only to be used during development, and SHOULD NOT be used in a production setting. """ import mimetypes import posixpath import re from pathlib import Path from django.http import ( FileResponse, Http404, HttpResponse, HttpResponseNotModified, ) from dja...
b375d2f3228b24e61a47b47fafc73edc5dc677c9e31598040ba3042b854c002e
import itertools import json import os import re from urllib.parse import unquote from django.apps import apps from django.conf import settings from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.template import Context, Engine from django.urls import translate_url from django.utils.fo...
43bab1b9c8d41cfa109a38d3fe9f777abc465cd68d2b64c73b8399ae14ccc3e9
from django.http import ( HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError, ) from django.template import Context, Engine, TemplateDoesNotExist, loader from django.views.decorators.csrf import requires_csrf_token ERROR_404_TEMPLATE_NAME = '404.html' ERROR_403_TEMPLAT...
91977f05ba59f09552b0522eb65e2dc5b3d3110691a9499eb88748a1662ee7d6
import functools import re import sys import types from pathlib import Path from django.conf import settings from django.http import HttpResponse, HttpResponseNotFound from django.template import Context, Engine, TemplateDoesNotExist from django.template.defaultfilters import pprint from django.urls import Resolver404...
4ce9d7112e70d01994bf2abbc21181e99e83b38f91a2d2156a698518df3c50a6
from django.conf import settings from django.http import HttpResponseForbidden from django.template import Context, Engine, TemplateDoesNotExist, loader from django.utils.translation import gettext as _ from django.utils.version import get_docs_version # We include the template inline since we need to be able to relia...
07a946ad3c5b288cc8eeff05a370c4b5f720dcde9c6ee3b905e3edb8ea1d25f2
""" Settings and configuration for Django. Read values from the module specified by the DJANGO_SETTINGS_MODULE environment variable, and then from django.conf.global_settings; see the global_settings.py for a list of all possible variables. """ import importlib import os import time import warnings from pathlib impor...
1f6a048afb46939936fb269646541f37717dc4ca5756844f51384418e5cf9567
""" Default Django settings. Override these with settings in the module pointed to by the DJANGO_SETTINGS_MODULE environment variable. """ # This is defined here as a do-nothing function because we can't import # django.utils.translation -- that module depends on the settings. def gettext_noop(s): return s ####...
bffcefa3c6000fb5baa0f0c21dee31b1a3daef36bcbe3ab3f0728749b14fd811
"Functions that help with dynamically creating decorators for views." # For backwards compatibility in Django 2.0. from contextlib import ContextDecorator # noqa from functools import WRAPPER_ASSIGNMENTS, update_wrapper, wraps class classonlymethod(classmethod): def __get__(self, instance, cls=None): if...
81ea02ddfb5e88f01e037b690b82d0d60f7ebdf60bab9e3e9174c246602b15d8
# Python's datetime strftime doesn't handle dates before 1900. # These classes override date and datetime to support the formatting of a date # through its full "proleptic Gregorian" date range. # # Based on code submitted to comp.lang.python by Andrew Dalke # # >>> datetime_safe.date(1850, 8, 2).strftime("%Y/%m/%d was...
1c1d9118789c16f582796ddcd83dabf4e1581310d0535f33d39eb9930cf4c733
# Autoreloading launcher. # Borrowed from Peter Hunt and the CherryPy project (http://www.cherrypy.org). # Some taken from Ian Bicking's Paste (http://pythonpaste.org/). # # Portions copyright (c) 2004, CherryPy Team (team@cherrypy.org) # All rights reserved. # # Redistribution and use in source and binary forms, with ...
bc3769edf1acb5e78b75685261a89dade62c94bd9f10f2e999bf93b3d7048482
import html.entities import re import unicodedata from gzip import GzipFile from io import BytesIO from django.utils.functional import ( SimpleLazyObject, keep_lazy, keep_lazy_text, lazy, ) from django.utils.safestring import SafeText, mark_safe from django.utils.translation import gettext as _, gettext_lazy, pget...
d4a35e4e0a013e765814cae3eb43f44ea95714a5111b94e4f72a6f119a242d58
"""Functions to parse datetime objects.""" # We're using regular expressions rather than time.strptime because: # - They provide both validation and parsing. # - They're more flexible for datetimes. # - The date/datetime/time constructors produce friendlier error messages. import datetime import re from django.utils...
07714e29a14dca7a747c2d7096222d3d22b3340052c9cfb4c7cf7b17b904563e
""" Utilities for XML generation/parsing. """ import re from collections import OrderedDict from xml.sax.saxutils import XMLGenerator class UnserializableContentError(ValueError): pass class SimplerXMLGenerator(XMLGenerator): def addQuickElement(self, name, contents=None, attrs=None): "Convenience ...
7537e6cd6a847f627366ad30c659c4443a2be9743ead6ede2bc33ed37da4385d
from decimal import Decimal from django.conf import settings from django.utils.safestring import mark_safe def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False): """ Get a number (as a number or string), and return it as a string, using formats de...
ea23f4e10b4801cdd0c84116b2f2c0ac58bbe0d9aab48197d2f62d1db4c9c839
import datetime import functools import os import subprocess import sys from distutils.version import LooseVersion # Private, stable API for detecting the Python version. PYXY means "Python X.Y # or later". So that third-party apps can use these values, each constant # should remain as long as the oldest supported Dja...
b51995cd776ca70d2129d6beea6daf0f45e054a1d98712e1dd1e802be12bba50
""" Timezone-related classes and functions. """ import datetime import functools from contextlib import ContextDecorator from datetime import timedelta, tzinfo from threading import local import pytz from django.conf import settings __all__ = [ 'utc', 'get_fixed_timezone', 'get_default_timezone', 'get_defau...
c6c574bcd11efe726c702b2cc90c424f1a34fb7c5086af057a32213667f1af58
""" A class for storing a tree graph. Primarily used for filter constructs in the ORM. """ import copy class Node: """ A single internal node in the tree graph. A Node should be viewed as a connection (the root) with the children being either leaf nodes or other Node instances. """ # Standard...
593e48045502659110457044de81054bd3b09be8c53ee7e31b398dce9c57921e
import inspect import warnings class RemovedInDjango30Warning(DeprecationWarning): pass class RemovedInDjango31Warning(PendingDeprecationWarning): pass RemovedInNextVersionWarning = RemovedInDjango30Warning class warn_about_renamed_method: def __init__(self, class_name, old_method_name, new_method_n...
e424239ebdf859618dd9aa1ebe7dc2a10cbc39999a201b562138b8fdec9b8d4d
import codecs import datetime import locale from decimal import Decimal from urllib.parse import quote from django.utils import six from django.utils.functional import Promise class DjangoUnicodeDecodeError(UnicodeDecodeError): def __init__(self, obj, *args): self.obj = obj super().__init__(*args...
208aa05e3b8f9d72ee7c263e9d7eb5a529c0bad56baff7105e74aaea3adcb4dc
""" Django's standard crypto functions and utilities. """ import hashlib import hmac import random import time from django.conf import settings from django.utils.encoding import force_bytes # Use the system PRNG if possible try: random = random.SystemRandom() using_sysrandom = True except NotImplementedError:...
e1a5ad4e983e5b108117755d8c4d33d50f66fb4bc48d4b388417f4c10dac78d9
""" Functions for reversing a regular expression (used in reverse URL resolving). Used internally by Django and not intended for external use. This is not, and is not intended to be, a complete reg-exp decompiler. It should be good enough for a large class of URLS, however. """ # Mapping of an escape character to a re...
e20facbcb526b2f9f6c254beacf1096c5aff383aa86abe6ac702231b1acb9710
from functools import lru_cache # noqa # Deprecate or remove this module when no supported version of Django still # supports Python 2. Until then, keep it to allow pluggable apps to support # Python 2 and Python 3 without raising a deprecation warning.
a26c42c813521a7df0abe2b53f1d796731001f6378e6b7c4a83706a737172c2d
import calendar import datetime from django.utils.html import avoid_wrapping from django.utils.timezone import is_aware, utc from django.utils.translation import gettext, ngettext_lazy TIME_STRINGS = { 'year': ngettext_lazy('%d year', '%d years'), 'month': ngettext_lazy('%d month', '%d months'), 'week': n...
41642f9adb5ea8ac399be10c8f864ad99c12c7e0ec954564f75cf43648a5ca5c
import inspect def get_func_args(func): sig = inspect.signature(func) return [ arg_name for arg_name, param in sig.parameters.items() if param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD ] def get_func_full_args(func): """ Return a list of (argument name, default value) tuple...
ce20ba72e3ea72fb04edd7da74984a8fb197da25709793b243e10d22dded80a0
import copy from collections import OrderedDict class OrderedSet: """ A set which keeps the ordering of the inserted items. Currently backs onto OrderedDict. """ def __init__(self, iterable=None): self.dict = OrderedDict.fromkeys(iterable or ()) def add(self, item): self.dict...
6325177b362a1bf47e84ca92878439d2ac937ef45e0ffe134c7543d9cd731f85
""" PHP date() style date formatting See http://www.php.net/date for format strings Usage: >>> import datetime >>> d = datetime.datetime.now() >>> df = DateFormat(d) >>> print(df.format('jS F Y H:i')) 7th October 2003 11:39 >>> """ import calendar import datetime import re import time from django.utils.dates import (...
ce64e514b01dbf6d018411e83c20c1053d8decf014ae461cb405031c5d6450fb
import copy import os from importlib import import_module from importlib.util import find_spec as importlib_find def import_string(dotted_path): """ Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed. """ try: ...
79ca1cafb18acad0a6a7d15bc8e2c3511e3fd2f9e070e8cc248b714c69d3455f
"""Utilities for writing code that runs on Python 2 and 3""" # Copyright (c) 2010-2015 Benjamin Peterson # # 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 with...
c5845e22a705d85143f3906a0eb978f31a385228c823d0fa6320be147b143dbc
# Copyright (c) 2010 Guilherme Gondim. All rights reserved. # Copyright (c) 2009 Simon Willison. All rights reserved. # Copyright (c) 2002 Drew Perttula. All rights reserved. # # License: # Python Software Foundation License version 2 # # See the file "LICENSE" for terms & conditions for usage, and a DISCLAIMER OF # ...
56d0d40102883c5bafe979301ba8088cb418b5cb3cbe018c712e0e429485c7e1
import datetime def _get_duration_components(duration): days = duration.days seconds = duration.seconds microseconds = duration.microseconds minutes = seconds // 60 seconds = seconds % 60 hours = minutes // 60 minutes = minutes % 60 return days, hours, minutes, seconds, microseconds...
865ee996eacd1c2eed8fff4e95bec7efe2c2b4e84e57bd685a0fb1c793c1161e
"Commonly-used date structures" from django.utils.translation import gettext_lazy as _, pgettext_lazy WEEKDAYS = { 0: _('Monday'), 1: _('Tuesday'), 2: _('Wednesday'), 3: _('Thursday'), 4: _('Friday'), 5: _('Saturday'), 6: _('Sunday') } WEEKDAYS_ABBR = { 0: _('Mon'), 1: _('Tue'), 2: _('Wed'), 3: _('Thu'), ...
f2cb41c660dd151158aa3fe4a2310e1de4b8423b25a03914d18eb80619f239fb
"""HTML utilities suitable for global use.""" import json import re from html.parser import HTMLParser from urllib.parse import ( parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit, ) from django.utils.functional import Promise, keep_lazy, keep_lazy_text from django.utils.http import RFC3986_GENDELIMS, RF...
1201c435796c66f6ceac6782c2114cf3d7199897ba14cb201b70c4e597f79b55
import logging import logging.config # needed when logging_config doesn't start with logging.config from copy import copy from django.conf import settings from django.core import mail from django.core.mail import get_connection from django.core.management.color import color_style from django.utils.module_loading impo...
cc8d054a843ea51b46cce3fcbe9c67f4178f1d7c93c4c361f617eb44d295e843
""" Functions for working with "safe strings": strings that can be displayed safely without further escaping in HTML. Marking something as a "safe string" means that the producer of the string has already turned characters that should not be interpreted by the HTML engine (e.g. '<') into the appropriate entities. """ ...
bdf9e6d7903abe0acbbe0ce129113da09bc785dd49bcab4329cd5189b11f0ae8
""" Based on "python-archive" -- https://pypi.org/project/python-archive/ Copyright (c) 2010 Gary Wilson Jr. <gary.wilson@gmail.com> and contributors. 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 Softw...
3ff0522ec2130cfd995bd1093f2e9c8859de89bd22cfd7b3073d8b0fb0958911
""" Utility functions for generating "lorem ipsum" Latin text. """ import random COMMON_P = ( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ' 'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim ' 'veniam, quis nostrud exercitation ullamco laboris nisi ut aliqu...
8044614cdaa00bb42b078689098a52663446c1173ebea64e51a3c0f8b8adc350
""" Syndication feed generation library -- used for generating RSS, etc. Sample usage: >>> from django.utils import feedgenerator >>> feed = feedgenerator.Rss201rev2Feed( ... title="Poynter E-Media Tidbits", ... link="http://www.poynter.org/column.asp?id=31", ... description="A group Weblog by the sharpes...
85c3bfeea6acb122397537d0e423edb40f2cddff72685f149ea28a99addb23a3
from importlib import import_module from django.utils.version import get_docs_version def deconstructible(*args, path=None): """ Class decorator that allows the decorated class to be serialized by the migrations subsystem. The `path` kwarg specifies the import path. """ def decorator(klass):...
c52436fa4c3568a79d97a6d442ff7826c282204f0355633c5368e33bc5c71e9c
import copy import itertools import operator from functools import total_ordering, wraps # You can't trivially replace this with `functools.partial` because this binds # to classes and returns bound instances, whereas functools.partial (on # CPython) is a type and its instances don't bind. def curry(_curried_func, *a...
58192665776d6c81e071a5832a6e04951bf3caeff028b096d9a035f20d51089a
import ipaddress from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ def clean_ipv6_address(ip_str, unpack_ipv4=False, error_message=_("This is not a valid IPv6 address.")): """ Clean an IPv6 address string. Raise ValidationErr...
95a7080e37338716f01b838dfca7c6d47e9534f3863a96d18675616de768d826
def is_iterable(x): "An implementation independent way of checking for iterables" try: iter(x) except TypeError: return False else: return True
8441023214f310ad94641abb489001b3cbfe2fafd023e54a691cfec4743ce66b
import base64 import calendar import datetime import re import unicodedata import warnings from binascii import Error as BinasciiError from email.utils import formatdate from urllib.parse import ( ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams, quote, quote_plus, scheme_chars, unquote, unquo...
9bd696429cb7df006c7c1c7ac5415bc2533f60e74169a5d8e05975eeaebed93f
""" This module contains helper functions for controlling caching. It does so by managing the "Vary" header of responses. It includes functions to patch the header of response objects directly and decorators that change functions to do that header-patching themselves. For information on the Vary header, see: http...
71b70d0fb05145c037156f4e5ca47465455c3e2a786c7cc33035e302ad5bae8a
import datetime import decimal import unicodedata from importlib import import_module from django.conf import settings from django.utils import dateformat, datetime_safe, numberformat from django.utils.functional import lazy from django.utils.translation import ( check_for_language, get_language, to_locale, ) # f...
8ce7acd247d9a0820fc4f30d5a45cc27a0f7c777fde41e5c656297a37f1185c7
"""JsLex: a lexer for Javascript""" # Originally from https://bitbucket.org/ned/jslex import re class Tok: """ A specification for a token class. """ num = 0 def __init__(self, name, regex, next=None): self.id = Tok.num Tok.num += 1 self.name = name self.regex = re...
098c66d49bb65f96e5d9f28ab18c8281e99676fe8b3e11220e4695dedff37f7d
import os import tempfile from os.path import abspath, dirname, join, normcase, sep from django.core.exceptions import SuspiciousFileOperation from django.utils.encoding import force_text # For backwards-compatibility in Django 2.0 abspathu = abspath def upath(path): """Always return a unicode path (did somethi...
26bcac6018c2ef6a2ad1604be84278e00f191228ff4bb42c8afa1142e8313c49
""" termcolors.py """ color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white') foreground = {color_names[x]: '3%s' % x for x in range(8)} background = {color_names[x]: '4%s' % x for x in range(8)} RESET = '0' opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conce...
b79a274f6e833929f2e108bb8b3fdaf36339589c9dbcfa646fa8458c4d35d021
""" Django's support for templates. The django.template namespace contains two independent subsystems: 1. Multiple Template Engines: support for pluggable template backends, built-in backends and backend-independent APIs 2. Django Template Language: Django's own template engine, including its built-in loaders, ...
fade5c4e7589af1b52dafca0f5c82ecf8ad7c654c19e2e17a0952ea8936094f2
from . import engines from .exceptions import TemplateDoesNotExist def get_template(template_name, using=None): """ Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists. """ chain = [] engines = _engine_list(using) for engine in engines: ...
6b077b07cd31845079ef82edd88748c870a90fa2861b2b8a1a42286a5afd75ea
""" This module contains generic exceptions used by template backends. Although, due to historical reasons, the Django template language also internally uses these exceptions, other exceptions specific to the DTL should not be added here. """ class TemplateDoesNotExist(Exception): """ The exception used when ...
741abdc10bd812f0ad1eaa5e2ba0e2c3ec9891c4296d50c878bdb69dc9082374
from django.http import HttpResponse from .loader import get_template, select_template class ContentNotRenderedError(Exception): pass class SimpleTemplateResponse(HttpResponse): rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks'] def __init__(self, template, context=None, con...