repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
mathiasertl/django-ca
ca/django_ca/managers.py
CertificateManager.sign_cert
def sign_cert(self, ca, csr, expires=None, algorithm=None, subject=None, cn_in_san=True, csr_format=Encoding.PEM, subject_alternative_name=None, key_usage=None, extended_key_usage=None, tls_feature=None, ocsp_no_check=False, extra_extensions=None, password=None): ...
python
def sign_cert(self, ca, csr, expires=None, algorithm=None, subject=None, cn_in_san=True, csr_format=Encoding.PEM, subject_alternative_name=None, key_usage=None, extended_key_usage=None, tls_feature=None, ocsp_no_check=False, extra_extensions=None, password=None): ...
Create a signed certificate from a CSR. **PLEASE NOTE:** This function creates the raw certificate and is usually not invoked directly. It is called by :py:func:`Certificate.objects.init() <django_ca.managers.CertificateManager.init>`, which passes along all parameters unchanged and saves the r...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/managers.py#L270-L440
mathiasertl/django-ca
ca/django_ca/managers.py
CertificateManager.init
def init(self, ca, csr, **kwargs): """Create a signed certificate from a CSR and store it to the database. All parameters are passed on to :py:func:`Certificate.objects.sign_cert() <django_ca.managers.CertificateManager.sign_cert>`. """ c = self.model(ca=ca) c.x509, csr...
python
def init(self, ca, csr, **kwargs): """Create a signed certificate from a CSR and store it to the database. All parameters are passed on to :py:func:`Certificate.objects.sign_cert() <django_ca.managers.CertificateManager.sign_cert>`. """ c = self.model(ca=ca) c.x509, csr...
Create a signed certificate from a CSR and store it to the database. All parameters are passed on to :py:func:`Certificate.objects.sign_cert() <django_ca.managers.CertificateManager.sign_cert>`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/managers.py#L442-L455
mathiasertl/django-ca
ca/django_ca/admin.py
CertificateMixin.download_bundle_view
def download_bundle_view(self, request, pk): """A view that allows the user to download a certificate bundle in PEM format.""" return self._download_response(request, pk, bundle=True)
python
def download_bundle_view(self, request, pk): """A view that allows the user to download a certificate bundle in PEM format.""" return self._download_response(request, pk, bundle=True)
A view that allows the user to download a certificate bundle in PEM format.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/admin.py#L118-L121
mathiasertl/django-ca
ca/django_ca/admin.py
CertificateMixin.get_actions
def get_actions(self, request): """Disable the "delete selected" admin action. Otherwise the action is present even though has_delete_permission is False, it just doesn't work. """ actions = super(CertificateMixin, self).get_actions(request) actions.pop('delete_selected'...
python
def get_actions(self, request): """Disable the "delete selected" admin action. Otherwise the action is present even though has_delete_permission is False, it just doesn't work. """ actions = super(CertificateMixin, self).get_actions(request) actions.pop('delete_selected'...
Disable the "delete selected" admin action. Otherwise the action is present even though has_delete_permission is False, it just doesn't work.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/admin.py#L126-L134
mathiasertl/django-ca
ca/django_ca/profiles.py
get_cert_profile_kwargs
def get_cert_profile_kwargs(name=None): """Get kwargs suitable for get_cert X509 keyword arguments from the given profile.""" if name is None: name = ca_settings.CA_DEFAULT_PROFILE profile = deepcopy(ca_settings.CA_PROFILES[name]) kwargs = { 'cn_in_san': profile['cn_in_san'], '...
python
def get_cert_profile_kwargs(name=None): """Get kwargs suitable for get_cert X509 keyword arguments from the given profile.""" if name is None: name = ca_settings.CA_DEFAULT_PROFILE profile = deepcopy(ca_settings.CA_PROFILES[name]) kwargs = { 'cn_in_san': profile['cn_in_san'], '...
Get kwargs suitable for get_cert X509 keyword arguments from the given profile.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/profiles.py#L25-L49
mathiasertl/django-ca
ca/django_ca/utils.py
format_name
def format_name(subject): """Convert a subject into the canonical form for distinguished names. This function does not take care of sorting the subject in any meaningful order. Examples:: >>> format_name([('CN', 'example.com'), ]) '/CN=example.com' >>> format_name([('CN', 'example...
python
def format_name(subject): """Convert a subject into the canonical form for distinguished names. This function does not take care of sorting the subject in any meaningful order. Examples:: >>> format_name([('CN', 'example.com'), ]) '/CN=example.com' >>> format_name([('CN', 'example...
Convert a subject into the canonical form for distinguished names. This function does not take care of sorting the subject in any meaningful order. Examples:: >>> format_name([('CN', 'example.com'), ]) '/CN=example.com' >>> format_name([('CN', 'example.com'), ('O', "My Organization"),...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L125-L140
mathiasertl/django-ca
ca/django_ca/utils.py
format_general_name
def format_general_name(name): """Format a single general name. >>> import ipaddress >>> format_general_name(x509.DNSName('example.com')) 'DNS:example.com' >>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1'))) 'IP:127.0.0.1' """ if isinstance(name, x509.DirectoryN...
python
def format_general_name(name): """Format a single general name. >>> import ipaddress >>> format_general_name(x509.DNSName('example.com')) 'DNS:example.com' >>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1'))) 'IP:127.0.0.1' """ if isinstance(name, x509.DirectoryN...
Format a single general name. >>> import ipaddress >>> format_general_name(x509.DNSName('example.com')) 'DNS:example.com' >>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1'))) 'IP:127.0.0.1'
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L143-L157
mathiasertl/django-ca
ca/django_ca/utils.py
add_colons
def add_colons(s): """Add colons after every second digit. This function is used in functions to prettify serials. >>> add_colons('teststring') 'te:st:st:ri:ng' """ return ':'.join([s[i:i + 2] for i in range(0, len(s), 2)])
python
def add_colons(s): """Add colons after every second digit. This function is used in functions to prettify serials. >>> add_colons('teststring') 'te:st:st:ri:ng' """ return ':'.join([s[i:i + 2] for i in range(0, len(s), 2)])
Add colons after every second digit. This function is used in functions to prettify serials. >>> add_colons('teststring') 'te:st:st:ri:ng'
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L200-L208
mathiasertl/django-ca
ca/django_ca/utils.py
int_to_hex
def int_to_hex(i): """Create a hex-representation of the given serial. >>> int_to_hex(12345678) 'BC:61:4E' """ s = hex(i)[2:].upper() if six.PY2 is True and isinstance(i, long): # pragma: only py2 # NOQA # Strip the "L" suffix, since hex(1L) -> 0x1L. # NOTE: Do not convert to ...
python
def int_to_hex(i): """Create a hex-representation of the given serial. >>> int_to_hex(12345678) 'BC:61:4E' """ s = hex(i)[2:].upper() if six.PY2 is True and isinstance(i, long): # pragma: only py2 # NOQA # Strip the "L" suffix, since hex(1L) -> 0x1L. # NOTE: Do not convert to ...
Create a hex-representation of the given serial. >>> int_to_hex(12345678) 'BC:61:4E'
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L211-L222
mathiasertl/django-ca
ca/django_ca/utils.py
parse_name
def parse_name(name): """Parses a subject string as used in OpenSSLs command line utilities. The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example ``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient on devi...
python
def parse_name(name): """Parses a subject string as used in OpenSSLs command line utilities. The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example ``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient on devi...
Parses a subject string as used in OpenSSLs command line utilities. The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example ``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient on deviations from the format, objec...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L245-L301
mathiasertl/django-ca
ca/django_ca/utils.py
x509_name
def x509_name(name): """Parses a subject into a :py:class:`x509.Name <cg:cryptography.x509.Name>`. If ``name`` is a string, :py:func:`parse_name` is used to parse it. >>> x509_name('/C=AT/CN=example.com') <Name(C=AT,CN=example.com)> >>> x509_name([('C', 'AT'), ('CN', 'example.com')]) <Name(C=A...
python
def x509_name(name): """Parses a subject into a :py:class:`x509.Name <cg:cryptography.x509.Name>`. If ``name`` is a string, :py:func:`parse_name` is used to parse it. >>> x509_name('/C=AT/CN=example.com') <Name(C=AT,CN=example.com)> >>> x509_name([('C', 'AT'), ('CN', 'example.com')]) <Name(C=A...
Parses a subject into a :py:class:`x509.Name <cg:cryptography.x509.Name>`. If ``name`` is a string, :py:func:`parse_name` is used to parse it. >>> x509_name('/C=AT/CN=example.com') <Name(C=AT,CN=example.com)> >>> x509_name([('C', 'AT'), ('CN', 'example.com')]) <Name(C=AT,CN=example.com)>
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L304-L317
mathiasertl/django-ca
ca/django_ca/utils.py
validate_email
def validate_email(addr): """Validate an email address. This function raises ``ValueError`` if the email address is not valid. >>> validate_email('foo@bar.com') 'foo@bar.com' >>> validate_email('foo@bar com') Traceback (most recent call last): ... ValueError: Invalid domain: bar co...
python
def validate_email(addr): """Validate an email address. This function raises ``ValueError`` if the email address is not valid. >>> validate_email('foo@bar.com') 'foo@bar.com' >>> validate_email('foo@bar com') Traceback (most recent call last): ... ValueError: Invalid domain: bar co...
Validate an email address. This function raises ``ValueError`` if the email address is not valid. >>> validate_email('foo@bar.com') 'foo@bar.com' >>> validate_email('foo@bar com') Traceback (most recent call last): ... ValueError: Invalid domain: bar com
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L320-L342
mathiasertl/django-ca
ca/django_ca/utils.py
parse_general_name
def parse_general_name(name): """Parse a general name from user input. This function will do its best to detect the intended type of any value passed to it: >>> parse_general_name('example.com') <DNSName(value='example.com')> >>> parse_general_name('*.example.com') <DNSName(value='*.example.co...
python
def parse_general_name(name): """Parse a general name from user input. This function will do its best to detect the intended type of any value passed to it: >>> parse_general_name('example.com') <DNSName(value='example.com')> >>> parse_general_name('*.example.com') <DNSName(value='*.example.co...
Parse a general name from user input. This function will do its best to detect the intended type of any value passed to it: >>> parse_general_name('example.com') <DNSName(value='example.com')> >>> parse_general_name('*.example.com') <DNSName(value='*.example.com')> >>> parse_general_name('.exa...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L345-L490
mathiasertl/django-ca
ca/django_ca/utils.py
parse_hash_algorithm
def parse_hash_algorithm(value=None): """Parse a hash algorithm value. The most common use case is to pass a str naming a class in :py:mod:`~cg:cryptography.hazmat.primitives.hashes`. For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM <settings-ca-digest-algorithm...
python
def parse_hash_algorithm(value=None): """Parse a hash algorithm value. The most common use case is to pass a str naming a class in :py:mod:`~cg:cryptography.hazmat.primitives.hashes`. For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM <settings-ca-digest-algorithm...
Parse a hash algorithm value. The most common use case is to pass a str naming a class in :py:mod:`~cg:cryptography.hazmat.primitives.hashes`. For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM <settings-ca-digest-algorithm>`, and passing an :py:class:`~cg:cryptog...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L493-L555
mathiasertl/django-ca
ca/django_ca/utils.py
parse_encoding
def parse_encoding(value=None): """Parse a value to a valid encoding. This function accepts either a member of :py:class:`~cg:cryptography.hazmat.primitives.serialization.Encoding` or a string describing a member. If no value is passed, it will assume ``PEM`` as a default value. Note that ``"ASN1"`` is...
python
def parse_encoding(value=None): """Parse a value to a valid encoding. This function accepts either a member of :py:class:`~cg:cryptography.hazmat.primitives.serialization.Encoding` or a string describing a member. If no value is passed, it will assume ``PEM`` as a default value. Note that ``"ASN1"`` is...
Parse a value to a valid encoding. This function accepts either a member of :py:class:`~cg:cryptography.hazmat.primitives.serialization.Encoding` or a string describing a member. If no value is passed, it will assume ``PEM`` as a default value. Note that ``"ASN1"`` is treated as an alias for ``"DER"``....
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L558-L586
mathiasertl/django-ca
ca/django_ca/utils.py
parse_key_curve
def parse_key_curve(value=None): """Parse an elliptic curve value. This function uses a value identifying an elliptic curve to return an :py:class:`~cg:cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` instance. The name must match a class name of one of the classes named under "Elliptic Curv...
python
def parse_key_curve(value=None): """Parse an elliptic curve value. This function uses a value identifying an elliptic curve to return an :py:class:`~cg:cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` instance. The name must match a class name of one of the classes named under "Elliptic Curv...
Parse an elliptic curve value. This function uses a value identifying an elliptic curve to return an :py:class:`~cg:cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` instance. The name must match a class name of one of the classes named under "Elliptic Curves" in :any:`cg:hazmat/primitives/as...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L589-L639
mathiasertl/django-ca
ca/django_ca/utils.py
get_cert_builder
def get_cert_builder(expires): """Get a basic X509 cert builder object. Parameters ---------- expires : datetime When this certificate will expire. """ now = datetime.utcnow().replace(second=0, microsecond=0) if expires is None: expires = get_expires(expires, now=now) ...
python
def get_cert_builder(expires): """Get a basic X509 cert builder object. Parameters ---------- expires : datetime When this certificate will expire. """ now = datetime.utcnow().replace(second=0, microsecond=0) if expires is None: expires = get_expires(expires, now=now) ...
Get a basic X509 cert builder object. Parameters ---------- expires : datetime When this certificate will expire.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L656-L676
mathiasertl/django-ca
ca/django_ca/utils.py
wrap_file_exceptions
def wrap_file_exceptions(): """Contextmanager to wrap file exceptions into identicaly exceptions in py2 and py3. This should be removed once py2 support is dropped. """ try: yield except (PermissionError, FileNotFoundError): # pragma: only py3 # In py3, we want to raise Exception u...
python
def wrap_file_exceptions(): """Contextmanager to wrap file exceptions into identicaly exceptions in py2 and py3. This should be removed once py2 support is dropped. """ try: yield except (PermissionError, FileNotFoundError): # pragma: only py3 # In py3, we want to raise Exception u...
Contextmanager to wrap file exceptions into identicaly exceptions in py2 and py3. This should be removed once py2 support is dropped.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L695-L711
mathiasertl/django-ca
ca/django_ca/utils.py
read_file
def read_file(path): """Read the file from the given path. If ``path`` is an absolute path, reads a file from the local filesystem. For relative paths, read the file using the storage backend configured using :ref:`CA_FILE_STORAGE <settings-ca-file-storage>`. """ if os.path.isabs(path): wit...
python
def read_file(path): """Read the file from the given path. If ``path`` is an absolute path, reads a file from the local filesystem. For relative paths, read the file using the storage backend configured using :ref:`CA_FILE_STORAGE <settings-ca-file-storage>`. """ if os.path.isabs(path): wit...
Read the file from the given path. If ``path`` is an absolute path, reads a file from the local filesystem. For relative paths, read the file using the storage backend configured using :ref:`CA_FILE_STORAGE <settings-ca-file-storage>`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L714-L731
mathiasertl/django-ca
ca/django_ca/utils.py
get_extension_name
def get_extension_name(ext): """Function to get the name of an extension.""" # In cryptography 2.2, SCTs return "Unknown OID" if ext.oid == ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: return 'SignedCertificateTimestampList' # Until at least cryptography 2.6.1, PrecertPoison has no name...
python
def get_extension_name(ext): """Function to get the name of an extension.""" # In cryptography 2.2, SCTs return "Unknown OID" if ext.oid == ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: return 'SignedCertificateTimestampList' # Until at least cryptography 2.6.1, PrecertPoison has no name...
Function to get the name of an extension.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L734-L748
mathiasertl/django-ca
ca/django_ca/utils.py
shlex_split
def shlex_split(s, sep): """Split a character on the given set of characters. Example:: >>> shlex_split('foo,bar', ', ') ['foo', 'bar'] >>> shlex_split('foo\\\\,bar1', ',') # escape a separator ['foo,bar1'] >>> shlex_split('"foo,bar", bla', ', ') ['foo,bar', 'b...
python
def shlex_split(s, sep): """Split a character on the given set of characters. Example:: >>> shlex_split('foo,bar', ', ') ['foo', 'bar'] >>> shlex_split('foo\\\\,bar1', ',') # escape a separator ['foo,bar1'] >>> shlex_split('"foo,bar", bla', ', ') ['foo,bar', 'b...
Split a character on the given set of characters. Example:: >>> shlex_split('foo,bar', ', ') ['foo', 'bar'] >>> shlex_split('foo\\\\,bar1', ',') # escape a separator ['foo,bar1'] >>> shlex_split('"foo,bar", bla', ', ') ['foo,bar', 'bla'] >>> shlex_split('fo...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L766-L783
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.get_revocation_reason
def get_revocation_reason(self): """Get the revocation reason of this certificate.""" if self.revoked is False: return if self.revoked_reason == '' or self.revoked_reason is None: return x509.ReasonFlags.unspecified else: return getattr(x509.ReasonFla...
python
def get_revocation_reason(self): """Get the revocation reason of this certificate.""" if self.revoked is False: return if self.revoked_reason == '' or self.revoked_reason is None: return x509.ReasonFlags.unspecified else: return getattr(x509.ReasonFla...
Get the revocation reason of this certificate.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L159-L167
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.get_revocation_time
def get_revocation_time(self): """Get the revocation time as naive datetime. Note that this method is only used by cryptography>=2.4. """ if self.revoked is False: return if timezone.is_aware(self.revoked_date): # convert datetime object to UTC and make ...
python
def get_revocation_time(self): """Get the revocation time as naive datetime. Note that this method is only used by cryptography>=2.4. """ if self.revoked is False: return if timezone.is_aware(self.revoked_date): # convert datetime object to UTC and make ...
Get the revocation time as naive datetime. Note that this method is only used by cryptography>=2.4.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L179-L191
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.x509
def x509(self): """The underlying :py:class:`cg:cryptography.x509.Certificate`.""" if self._x509 is None: backend = default_backend() self._x509 = x509.load_pem_x509_certificate(force_bytes(self.pub), backend) return self._x509
python
def x509(self): """The underlying :py:class:`cg:cryptography.x509.Certificate`.""" if self._x509 is None: backend = default_backend() self._x509 = x509.load_pem_x509_certificate(force_bytes(self.pub), backend) return self._x509
The underlying :py:class:`cg:cryptography.x509.Certificate`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L194-L199
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.issuer
def issuer(self): """The certificate issuer field as :py:class:`~django_ca.subject.Subject`.""" return Subject([(s.oid, s.value) for s in self.x509.issuer])
python
def issuer(self): """The certificate issuer field as :py:class:`~django_ca.subject.Subject`.""" return Subject([(s.oid, s.value) for s in self.x509.issuer])
The certificate issuer field as :py:class:`~django_ca.subject.Subject`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L272-L274
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.subject
def subject(self): """The certificates subject as :py:class:`~django_ca.subject.Subject`.""" return Subject([(s.oid, s.value) for s in self.x509.subject])
python
def subject(self): """The certificates subject as :py:class:`~django_ca.subject.Subject`.""" return Subject([(s.oid, s.value) for s in self.x509.subject])
The certificates subject as :py:class:`~django_ca.subject.Subject`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L306-L308
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.authority_key_identifier
def authority_key_identifier(self): """The :py:class:`~django_ca.extensions.AuthorityKeyIdentifier` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.AUTHORITY_KEY_IDENTIFIER) except x509.ExtensionNotFound: ...
python
def authority_key_identifier(self): """The :py:class:`~django_ca.extensions.AuthorityKeyIdentifier` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.AUTHORITY_KEY_IDENTIFIER) except x509.ExtensionNotFound: ...
The :py:class:`~django_ca.extensions.AuthorityKeyIdentifier` extension, or ``None`` if it doesn't exist.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L381-L388
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.key_usage
def key_usage(self): """The :py:class:`~django_ca.extensions.KeyUsage` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.KEY_USAGE) except x509.ExtensionNotFound: return None return KeyUsage(ext)
python
def key_usage(self): """The :py:class:`~django_ca.extensions.KeyUsage` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.KEY_USAGE) except x509.ExtensionNotFound: return None return KeyUsage(ext)
The :py:class:`~django_ca.extensions.KeyUsage` extension, or ``None`` if it doesn't exist.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L408-L414
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.extended_key_usage
def extended_key_usage(self): """The :py:class:`~django_ca.extensions.ExtendedKeyUsage` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.EXTENDED_KEY_USAGE) except x509.ExtensionNotFound: return None...
python
def extended_key_usage(self): """The :py:class:`~django_ca.extensions.ExtendedKeyUsage` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.EXTENDED_KEY_USAGE) except x509.ExtensionNotFound: return None...
The :py:class:`~django_ca.extensions.ExtendedKeyUsage` extension, or ``None`` if it doesn't exist.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L417-L424
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.subject_key_identifier
def subject_key_identifier(self): """The :py:class:`~django_ca.extensions.SubjectKeyIdentifier` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_KEY_IDENTIFIER) except x509.ExtensionNotFound: ...
python
def subject_key_identifier(self): """The :py:class:`~django_ca.extensions.SubjectKeyIdentifier` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_KEY_IDENTIFIER) except x509.ExtensionNotFound: ...
The :py:class:`~django_ca.extensions.SubjectKeyIdentifier` extension, or ``None`` if it doesn't exist.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L481-L488
mathiasertl/django-ca
ca/django_ca/models.py
X509CertMixin.tls_feature
def tls_feature(self): """The :py:class:`~django_ca.extensions.TLSFeature` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.TLS_FEATURE) except x509.ExtensionNotFound: return None return TLSFeature(e...
python
def tls_feature(self): """The :py:class:`~django_ca.extensions.TLSFeature` extension, or ``None`` if it doesn't exist.""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.TLS_FEATURE) except x509.ExtensionNotFound: return None return TLSFeature(e...
The :py:class:`~django_ca.extensions.TLSFeature` extension, or ``None`` if it doesn't exist.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L491-L497
mathiasertl/django-ca
ca/django_ca/models.py
CertificateAuthority.get_authority_key_identifier
def get_authority_key_identifier(self): """Return the AuthorityKeyIdentifier extension used in certificates signed by this CA.""" try: ski = self.x509.extensions.get_extension_for_class(x509.SubjectKeyIdentifier) except x509.ExtensionNotFound: return x509.AuthorityKeyIde...
python
def get_authority_key_identifier(self): """Return the AuthorityKeyIdentifier extension used in certificates signed by this CA.""" try: ski = self.x509.extensions.get_extension_for_class(x509.SubjectKeyIdentifier) except x509.ExtensionNotFound: return x509.AuthorityKeyIde...
Return the AuthorityKeyIdentifier extension used in certificates signed by this CA.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L598-L606
mathiasertl/django-ca
ca/django_ca/models.py
CertificateAuthority.get_crl
def get_crl(self, expires=86400, encoding=None, algorithm=None, password=None, scope=None, **kwargs): """Generate a Certificate Revocation List (CRL). The ``full_name`` and ``relative_name`` parameters describe how to retrieve the CRL and are used in the `Issuing Distribution Point extension <h...
python
def get_crl(self, expires=86400, encoding=None, algorithm=None, password=None, scope=None, **kwargs): """Generate a Certificate Revocation List (CRL). The ``full_name`` and ``relative_name`` parameters describe how to retrieve the CRL and are used in the `Issuing Distribution Point extension <h...
Generate a Certificate Revocation List (CRL). The ``full_name`` and ``relative_name`` parameters describe how to retrieve the CRL and are used in the `Issuing Distribution Point extension <https://tools.ietf.org/html/rfc5280.html#section-5.2.5>`_. The former defaults to the ``crl_url`` field, p...
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L608-L708
mathiasertl/django-ca
ca/django_ca/models.py
CertificateAuthority.pathlen
def pathlen(self): """The ``pathlen`` attribute of the ``BasicConstraints`` extension (either an ``int`` or ``None``).""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS) except x509.ExtensionNotFound: # pragma: no cover - extension should alway...
python
def pathlen(self): """The ``pathlen`` attribute of the ``BasicConstraints`` extension (either an ``int`` or ``None``).""" try: ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS) except x509.ExtensionNotFound: # pragma: no cover - extension should alway...
The ``pathlen`` attribute of the ``BasicConstraints`` extension (either an ``int`` or ``None``).
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L711-L718
mathiasertl/django-ca
ca/django_ca/models.py
CertificateAuthority.max_pathlen
def max_pathlen(self): """The maximum pathlen for any intermediate CAs signed by this CA. This value is either ``None``, if this and all parent CAs don't have a ``pathlen`` attribute, or an ``int`` if any parent CA has the attribute. """ pathlen = self.pathlen if self.p...
python
def max_pathlen(self): """The maximum pathlen for any intermediate CAs signed by this CA. This value is either ``None``, if this and all parent CAs don't have a ``pathlen`` attribute, or an ``int`` if any parent CA has the attribute. """ pathlen = self.pathlen if self.p...
The maximum pathlen for any intermediate CAs signed by this CA. This value is either ``None``, if this and all parent CAs don't have a ``pathlen`` attribute, or an ``int`` if any parent CA has the attribute.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L721-L739
mathiasertl/django-ca
ca/django_ca/models.py
CertificateAuthority.bundle
def bundle(self): """A list of any parent CAs, including this CA. The list is ordered so the Root CA will be the first. """ ca = self bundle = [ca] while ca.parent is not None: bundle.append(ca.parent) ca = ca.parent return bundle
python
def bundle(self): """A list of any parent CAs, including this CA. The list is ordered so the Root CA will be the first. """ ca = self bundle = [ca] while ca.parent is not None: bundle.append(ca.parent) ca = ca.parent return bundle
A list of any parent CAs, including this CA. The list is ordered so the Root CA will be the first.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L749-L760
mathiasertl/django-ca
ca/django_ca/querysets.py
CertificateQuerySet.valid
def valid(self): """Return valid certificates.""" now = timezone.now() return self.filter(revoked=False, expires__gt=now, valid_from__lt=now)
python
def valid(self): """Return valid certificates.""" now = timezone.now() return self.filter(revoked=False, expires__gt=now, valid_from__lt=now)
Return valid certificates.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/querysets.py#L45-L49
mathiasertl/django-ca
ca/django_ca/extensions.py
NullExtension.as_extension
def as_extension(self): """This extension as :py:class:`~cg:cryptography.x509.ExtensionType`.""" return x509.extensions.Extension(oid=self.oid, critical=self.critical, value=self.extension_type)
python
def as_extension(self): """This extension as :py:class:`~cg:cryptography.x509.ExtensionType`.""" return x509.extensions.Extension(oid=self.oid, critical=self.critical, value=self.extension_type)
This extension as :py:class:`~cg:cryptography.x509.ExtensionType`.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/extensions.py#L250-L252
mathiasertl/django-ca
ca/django_ca/management/base.py
BaseCommand.add_algorithm
def add_algorithm(self, parser): """Add the --algorithm option.""" help = 'The HashAlgorithm that will be used to generate the signature (default: %(default)s).' % { 'default': ca_settings.CA_DIGEST_ALGORITHM.name, } parser.add_argument( '--algorithm', metavar='{sha512,...
python
def add_algorithm(self, parser): """Add the --algorithm option.""" help = 'The HashAlgorithm that will be used to generate the signature (default: %(default)s).' % { 'default': ca_settings.CA_DIGEST_ALGORITHM.name, } parser.add_argument( '--algorithm', metavar='{sha512,...
Add the --algorithm option.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/management/base.py#L251-L259
mathiasertl/django-ca
ca/django_ca/management/base.py
BaseCommand.add_format
def add_format(self, parser, default=Encoding.PEM, help_text=None, opts=None): """Add the --format option.""" if opts is None: opts = ['-f', '--format'] if help_text is None: help_text = 'The format to use ("ASN1" is an alias for "DER", default: %(default)s).' he...
python
def add_format(self, parser, default=Encoding.PEM, help_text=None, opts=None): """Add the --format option.""" if opts is None: opts = ['-f', '--format'] if help_text is None: help_text = 'The format to use ("ASN1" is an alias for "DER", default: %(default)s).' he...
Add the --format option.
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/management/base.py#L281-L290
saltstack/salt-pylint
saltpylint/fileperms.py
FilePermsChecker.process_module
def process_module(self, node): ''' process a module ''' for listing in self.config.fileperms_ignore_paths: if node.file.split('{0}/'.format(os.getcwd()))[-1] in glob.glob(listing): # File is ignored, no checking should be done return ...
python
def process_module(self, node): ''' process a module ''' for listing in self.config.fileperms_ignore_paths: if node.file.split('{0}/'.format(os.getcwd()))[-1] in glob.glob(listing): # File is ignored, no checking should be done return ...
process a module
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/fileperms.py#L52-L117
saltstack/salt-pylint
setup.py
_parse_requirements_file
def _parse_requirements_file(requirements_file): ''' Parse requirements.txt and return list suitable for passing to ``install_requires`` parameter in ``setup()``. ''' parsed_requirements = [] with open(requirements_file) as rfh: for line in rfh.readlines(): line = line.strip(...
python
def _parse_requirements_file(requirements_file): ''' Parse requirements.txt and return list suitable for passing to ``install_requires`` parameter in ``setup()``. ''' parsed_requirements = [] with open(requirements_file) as rfh: for line in rfh.readlines(): line = line.strip(...
Parse requirements.txt and return list suitable for passing to ``install_requires`` parameter in ``setup()``.
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/setup.py#L30-L42
saltstack/salt-pylint
setup.py
_release_version
def _release_version(): ''' Returns release version ''' with io.open(os.path.join(SETUP_DIRNAME, 'saltpylint', 'version.py'), encoding='utf-8') as fh_: exec_locals = {} exec_globals = {} contents = fh_.read() if not isinstance(contents, str): contents = conten...
python
def _release_version(): ''' Returns release version ''' with io.open(os.path.join(SETUP_DIRNAME, 'saltpylint', 'version.py'), encoding='utf-8') as fh_: exec_locals = {} exec_globals = {} contents = fh_.read() if not isinstance(contents, str): contents = conten...
Returns release version
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/setup.py#L45-L56
saltstack/salt-pylint
saltpylint/py3modernize/__init__.py
Py3Modernize.process_module
def process_module(self, node): ''' process a module ''' # Patch lib2to3.fixer_util.touch_import! fixer_util.touch_import = salt_lib2to3_touch_import flags = {} if self.config.modernize_print_function: flags['print_function'] = True salt_av...
python
def process_module(self, node): ''' process a module ''' # Patch lib2to3.fixer_util.touch_import! fixer_util.touch_import = salt_lib2to3_touch_import flags = {} if self.config.modernize_print_function: flags['print_function'] = True salt_av...
process a module
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/py3modernize/__init__.py#L144-L239
saltstack/salt-pylint
saltpylint/virt.py
VirtChecker.visit_functiondef
def visit_functiondef(self, node): ''' Verifies no logger statements inside __virtual__ ''' if (not isinstance(node, astroid.FunctionDef) or node.is_method() or node.type != 'function' or not node.body ): # only process functions...
python
def visit_functiondef(self, node): ''' Verifies no logger statements inside __virtual__ ''' if (not isinstance(node, astroid.FunctionDef) or node.is_method() or node.type != 'function' or not node.body ): # only process functions...
Verifies no logger statements inside __virtual__
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/virt.py#L26-L65
saltstack/salt-pylint
saltpylint/pep263.py
FileEncodingChecker.process_module
def process_module(self, node): ''' process a module the module's content is accessible via node.file_stream object ''' pep263 = re.compile(six.b(self.RE_PEP263)) try: file_stream = node.file_stream except AttributeError: # Pylint >= 1.8....
python
def process_module(self, node): ''' process a module the module's content is accessible via node.file_stream object ''' pep263 = re.compile(six.b(self.RE_PEP263)) try: file_stream = node.file_stream except AttributeError: # Pylint >= 1.8....
process a module the module's content is accessible via node.file_stream object
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/pep263.py#L57-L110
saltstack/salt-pylint
saltpylint/ext/pyqver2.py
get_versions
def get_versions(source): """Return information about the Python versions required for specific features. The return value is a dictionary with keys as a version number as a tuple (for example Python 2.6 is (2,6)) and the value are a list of features that require the indicated Python version. """ ...
python
def get_versions(source): """Return information about the Python versions required for specific features. The return value is a dictionary with keys as a version number as a tuple (for example Python 2.6 is (2,6)) and the value are a list of features that require the indicated Python version. """ ...
Return information about the Python versions required for specific features. The return value is a dictionary with keys as a version number as a tuple (for example Python 2.6 is (2,6)) and the value are a list of features that require the indicated Python version.
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/ext/pyqver2.py#L252-L261
saltstack/salt-pylint
saltpylint/strings.py
register
def register(linter): '''required method to auto register this checker ''' linter.register_checker(StringCurlyBracesFormatIndexChecker(linter)) linter.register_checker(StringLiteralChecker(linter))
python
def register(linter): '''required method to auto register this checker ''' linter.register_checker(StringCurlyBracesFormatIndexChecker(linter)) linter.register_checker(StringLiteralChecker(linter))
required method to auto register this checker
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/strings.py#L260-L263
saltstack/salt-pylint
saltpylint/strings.py
StringLiteralChecker.process_non_raw_string_token
def process_non_raw_string_token(self, prefix, string_body, start_row): ''' check for bad escapes in a non-raw string. prefix: lowercase string of eg 'ur' string prefix markers. string_body: the un-parsed body of the string, not including the quote marks. start_row: inte...
python
def process_non_raw_string_token(self, prefix, string_body, start_row): ''' check for bad escapes in a non-raw string. prefix: lowercase string of eg 'ur' string prefix markers. string_body: the un-parsed body of the string, not including the quote marks. start_row: inte...
check for bad escapes in a non-raw string. prefix: lowercase string of eg 'ur' string prefix markers. string_body: the un-parsed body of the string, not including the quote marks. start_row: integer line number in the source.
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/strings.py#L247-L258
saltstack/salt-pylint
saltpylint/blacklist.py
register
def register(linter): ''' Required method to auto register this checker ''' linter.register_checker(ResourceLeakageChecker(linter)) linter.register_checker(BlacklistedImportsChecker(linter)) linter.register_checker(MovedTestCaseClassChecker(linter)) linter.register_checker(BlacklistedLoaderM...
python
def register(linter): ''' Required method to auto register this checker ''' linter.register_checker(ResourceLeakageChecker(linter)) linter.register_checker(BlacklistedImportsChecker(linter)) linter.register_checker(MovedTestCaseClassChecker(linter)) linter.register_checker(BlacklistedLoaderM...
Required method to auto register this checker
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L560-L568
saltstack/salt-pylint
saltpylint/blacklist.py
BlacklistedImportsChecker.visit_import
def visit_import(self, node): '''triggered when an import statement is seen''' module_filename = node.root().file if fnmatch.fnmatch(module_filename, '__init__.py*') and \ not fnmatch.fnmatch(module_filename, 'test_*.py*'): return modnode = node.root() ...
python
def visit_import(self, node): '''triggered when an import statement is seen''' module_filename = node.root().file if fnmatch.fnmatch(module_filename, '__init__.py*') and \ not fnmatch.fnmatch(module_filename, 'test_*.py*'): return modnode = node.root() ...
triggered when an import statement is seen
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L66-L76
saltstack/salt-pylint
saltpylint/blacklist.py
BlacklistedImportsChecker.visit_importfrom
def visit_importfrom(self, node): '''triggered when a from statement is seen''' module_filename = node.root().file if fnmatch.fnmatch(module_filename, '__init__.py*') and \ not fnmatch.fnmatch(module_filename, 'test_*.py*'): return basename = node.modname ...
python
def visit_importfrom(self, node): '''triggered when a from statement is seen''' module_filename = node.root().file if fnmatch.fnmatch(module_filename, '__init__.py*') and \ not fnmatch.fnmatch(module_filename, 'test_*.py*'): return basename = node.modname ...
triggered when a from statement is seen
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L79-L86
saltstack/salt-pylint
saltpylint/blacklist.py
BlacklistedImportsChecker._check_blacklisted_module
def _check_blacklisted_module(self, node, mod_path): '''check if the module is blacklisted''' for mod_name in self.blacklisted_modules: if mod_path == mod_name or mod_path.startswith(mod_name + '.'): names = [] for name, name_as in node.names: ...
python
def _check_blacklisted_module(self, node, mod_path): '''check if the module is blacklisted''' for mod_name in self.blacklisted_modules: if mod_path == mod_name or mod_path.startswith(mod_name + '.'): names = [] for name, name_as in node.names: ...
check if the module is blacklisted
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L88-L221
saltstack/salt-pylint
saltpylint/blacklist.py
BlacklistedLoaderModulesUsageChecker.visit_import
def visit_import(self, node): '''triggered when an import statement is seen''' if self.process_module: # Store salt imported modules for module, import_as in node.names: if not module.startswith('salt'): continue if import_as an...
python
def visit_import(self, node): '''triggered when an import statement is seen''' if self.process_module: # Store salt imported modules for module, import_as in node.names: if not module.startswith('salt'): continue if import_as an...
triggered when an import statement is seen
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L277-L288
saltstack/salt-pylint
saltpylint/blacklist.py
BlacklistedLoaderModulesUsageChecker.visit_importfrom
def visit_importfrom(self, node): '''triggered when a from statement is seen''' if self.process_module: if not node.modname.startswith('salt'): return # Store salt imported modules for module, import_as in node.names: if import_as and i...
python
def visit_importfrom(self, node): '''triggered when a from statement is seen''' if self.process_module: if not node.modname.startswith('salt'): return # Store salt imported modules for module, import_as in node.names: if import_as and i...
triggered when a from statement is seen
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/blacklist.py#L291-L302
saltstack/salt-pylint
saltpylint/smartup.py
register
def register(linter): ''' Register the transformation functions. ''' try: MANAGER.register_transform(nodes.Class, rootlogger_transform) except AttributeError: MANAGER.register_transform(nodes.ClassDef, rootlogger_transform)
python
def register(linter): ''' Register the transformation functions. ''' try: MANAGER.register_transform(nodes.Class, rootlogger_transform) except AttributeError: MANAGER.register_transform(nodes.ClassDef, rootlogger_transform)
Register the transformation functions.
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/smartup.py#L39-L46
saltstack/salt-pylint
saltpylint/pep8.py
register
def register(linter): ''' required method to auto register this checker ''' if HAS_PEP8 is False: return linter.register_checker(PEP8Indentation(linter)) linter.register_checker(PEP8Whitespace(linter)) linter.register_checker(PEP8BlankLine(linter)) linter.register_checker(PEP8Im...
python
def register(linter): ''' required method to auto register this checker ''' if HAS_PEP8 is False: return linter.register_checker(PEP8Indentation(linter)) linter.register_checker(PEP8Whitespace(linter)) linter.register_checker(PEP8BlankLine(linter)) linter.register_checker(PEP8Im...
required method to auto register this checker
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/pep8.py#L462-L479
saltstack/salt-pylint
saltpylint/pep8.py
_PEP8BaseChecker.process_module
def process_module(self, node): ''' process a module the module's content is accessible via node.file_stream object ''' nodepaths = [] if not isinstance(node.path, list): nodepaths = [node.path] else: nodepaths = node.path for nod...
python
def process_module(self, node): ''' process a module the module's content is accessible via node.file_stream object ''' nodepaths = [] if not isinstance(node.path, list): nodepaths = [node.path] else: nodepaths = node.path for nod...
process a module the module's content is accessible via node.file_stream object
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/pep8.py#L90-L145
saltstack/salt-pylint
saltpylint/minpyver.py
MininumPythonVersionChecker.process_module
def process_module(self, node): ''' process a module ''' if not HAS_PYQVER: return minimum_version = tuple([int(x) for x in self.config.minimum_python_version.split('.')]) with open(node.path, 'r') as rfh: for version, reasons in pyqver2.get_versi...
python
def process_module(self, node): ''' process a module ''' if not HAS_PYQVER: return minimum_version = tuple([int(x) for x in self.config.minimum_python_version.split('.')]) with open(node.path, 'r') as rfh: for version, reasons in pyqver2.get_versi...
process a module
https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/minpyver.py#L59-L74
edx/xblock-utils
xblockutils/settings.py
XBlockWithSettingsMixin.get_xblock_settings
def get_xblock_settings(self, default=None): """ Gets XBlock-specific settigns for current XBlock Returns default if settings service is not available. Parameters: default - default value to be used in two cases: * No settings service is available ...
python
def get_xblock_settings(self, default=None): """ Gets XBlock-specific settigns for current XBlock Returns default if settings service is not available. Parameters: default - default value to be used in two cases: * No settings service is available ...
Gets XBlock-specific settigns for current XBlock Returns default if settings service is not available. Parameters: default - default value to be used in two cases: * No settings service is available * As a `default` parameter to `SettingsService....
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/settings.py#L25-L39
edx/xblock-utils
xblockutils/settings.py
ThemableXBlockMixin.get_theme
def get_theme(self): """ Gets theme settings from settings service. Falls back to default (LMS) theme if settings service is not available, xblock theme settings are not set or does contain mentoring theme settings. """ xblock_settings = self.get_xblock_settings(default={...
python
def get_theme(self): """ Gets theme settings from settings service. Falls back to default (LMS) theme if settings service is not available, xblock theme settings are not set or does contain mentoring theme settings. """ xblock_settings = self.get_xblock_settings(default={...
Gets theme settings from settings service. Falls back to default (LMS) theme if settings service is not available, xblock theme settings are not set or does contain mentoring theme settings.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/settings.py#L70-L79
edx/xblock-utils
xblockutils/settings.py
ThemableXBlockMixin.include_theme_files
def include_theme_files(self, fragment): """ Gets theme configuration and renders theme css into fragment """ theme = self.get_theme() if not theme or 'package' not in theme: return theme_package, theme_files = theme.get('package', None), theme.get('locations...
python
def include_theme_files(self, fragment): """ Gets theme configuration and renders theme css into fragment """ theme = self.get_theme() if not theme or 'package' not in theme: return theme_package, theme_files = theme.get('package', None), theme.get('locations...
Gets theme configuration and renders theme css into fragment
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/settings.py#L81-L92
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.load_unicode
def load_unicode(self, resource_path): """ Gets the content of a resource """ resource_content = pkg_resources.resource_string(self.module_name, resource_path) return resource_content.decode('utf-8')
python
def load_unicode(self, resource_path): """ Gets the content of a resource """ resource_content = pkg_resources.resource_string(self.module_name, resource_path) return resource_content.decode('utf-8')
Gets the content of a resource
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L46-L51
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.render_django_template
def render_django_template(self, template_path, context=None, i18n_service=None): """ Evaluate a django template by resource path, applying the provided context. """ context = context or {} context['_i18n_service'] = i18n_service libraries = { 'i18n': 'xblocku...
python
def render_django_template(self, template_path, context=None, i18n_service=None): """ Evaluate a django template by resource path, applying the provided context. """ context = context or {} context['_i18n_service'] = i18n_service libraries = { 'i18n': 'xblocku...
Evaluate a django template by resource path, applying the provided context.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L53-L88
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.render_mako_template
def render_mako_template(self, template_path, context=None): """ Evaluate a mako template by resource path, applying the provided context """ context = context or {} template_str = self.load_unicode(template_path) lookup = MakoTemplateLookup(directories=[pkg_resources.res...
python
def render_mako_template(self, template_path, context=None): """ Evaluate a mako template by resource path, applying the provided context """ context = context or {} template_str = self.load_unicode(template_path) lookup = MakoTemplateLookup(directories=[pkg_resources.res...
Evaluate a mako template by resource path, applying the provided context
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L90-L98
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.render_template
def render_template(self, template_path, context=None): """ This function has been deprecated. It calls render_django_template to support backwards compatibility. """ warnings.warn( "ResourceLoader.render_template has been deprecated in favor of ResourceLoader.render_django_t...
python
def render_template(self, template_path, context=None): """ This function has been deprecated. It calls render_django_template to support backwards compatibility. """ warnings.warn( "ResourceLoader.render_template has been deprecated in favor of ResourceLoader.render_django_t...
This function has been deprecated. It calls render_django_template to support backwards compatibility.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L100-L107
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.render_js_template
def render_js_template(self, template_path, element_id, context=None): """ Render a js template. """ context = context or {} return u"<script type='text/template' id='{}'>\n{}\n</script>".format( element_id, self.render_template(template_path, context) ...
python
def render_js_template(self, template_path, element_id, context=None): """ Render a js template. """ context = context or {} return u"<script type='text/template' id='{}'>\n{}\n</script>".format( element_id, self.render_template(template_path, context) ...
Render a js template.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L109-L117
edx/xblock-utils
xblockutils/resources.py
ResourceLoader.load_scenarios_from_path
def load_scenarios_from_path(self, relative_scenario_dir, include_identifier=False): """ Returns an array of (title, xmlcontent) from files contained in a specified directory, formatted as expected for the return value of the workbench_scenarios() method. If `include_identifier` is True...
python
def load_scenarios_from_path(self, relative_scenario_dir, include_identifier=False): """ Returns an array of (title, xmlcontent) from files contained in a specified directory, formatted as expected for the return value of the workbench_scenarios() method. If `include_identifier` is True...
Returns an array of (title, xmlcontent) from files contained in a specified directory, formatted as expected for the return value of the workbench_scenarios() method. If `include_identifier` is True, returns an array of (identifier, title, xmlcontent).
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/resources.py#L119-L143
edx/xblock-utils
xblockutils/templatetags/i18n.py
ProxyTransNode.merge_translation
def merge_translation(self, context): """ Context wrapper which modifies the given language's translation catalog using the i18n service, if found. """ language = get_language() i18n_service = context.get('_i18n_service', None) if i18n_service: # Cache the ori...
python
def merge_translation(self, context): """ Context wrapper which modifies the given language's translation catalog using the i18n service, if found. """ language = get_language() i18n_service = context.get('_i18n_service', None) if i18n_service: # Cache the ori...
Context wrapper which modifies the given language's translation catalog using the i18n service, if found.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/templatetags/i18n.py#L29-L49
edx/xblock-utils
xblockutils/templatetags/i18n.py
ProxyTransNode.render
def render(self, context): """ Renders the translated text using the XBlock i18n service, if available. """ with self.merge_translation(context): django_translated = self.do_translate.render(context) return django_translated
python
def render(self, context): """ Renders the translated text using the XBlock i18n service, if available. """ with self.merge_translation(context): django_translated = self.do_translate.render(context) return django_translated
Renders the translated text using the XBlock i18n service, if available.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/templatetags/i18n.py#L51-L58
edx/xblock-utils
xblockutils/studio_editable.py
StudioEditableXBlockMixin.studio_view
def studio_view(self, context): """ Render a form for editing this XBlock """ fragment = Fragment() context = {'fields': []} # Build a list of all the fields that can be edited: for field_name in self.editable_fields: field = self.fields[field_name] ...
python
def studio_view(self, context): """ Render a form for editing this XBlock """ fragment = Fragment() context = {'fields': []} # Build a list of all the fields that can be edited: for field_name in self.editable_fields: field = self.fields[field_name] ...
Render a form for editing this XBlock
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L78-L98
edx/xblock-utils
xblockutils/studio_editable.py
StudioEditableXBlockMixin._make_field_info
def _make_field_info(self, field_name, field): """ Create the information that the template needs to render a form field for this field. """ supported_field_types = ( (Integer, 'integer'), (Float, 'float'), (Boolean, 'boolean'), (String, 's...
python
def _make_field_info(self, field_name, field): """ Create the information that the template needs to render a form field for this field. """ supported_field_types = ( (Integer, 'integer'), (Float, 'float'), (Boolean, 'boolean'), (String, 's...
Create the information that the template needs to render a form field for this field.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L100-L202
edx/xblock-utils
xblockutils/studio_editable.py
StudioEditableXBlockMixin.submit_studio_edits
def submit_studio_edits(self, data, suffix=''): """ AJAX handler for studio_view() Save button """ values = {} # dict of new field values we are updating to_reset = [] # list of field names to delete from this XBlock for field_name in self.editable_fields: f...
python
def submit_studio_edits(self, data, suffix=''): """ AJAX handler for studio_view() Save button """ values = {} # dict of new field values we are updating to_reset = [] # list of field names to delete from this XBlock for field_name in self.editable_fields: f...
AJAX handler for studio_view() Save button
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L205-L237
edx/xblock-utils
xblockutils/studio_editable.py
StudioEditableXBlockMixin.validate
def validate(self): """ Validates the state of this XBlock. Subclasses should override validate_field_data() to validate fields and override this only for validation not related to this block's field values. """ validation = super(StudioEditableXBlockMixin, self).validat...
python
def validate(self): """ Validates the state of this XBlock. Subclasses should override validate_field_data() to validate fields and override this only for validation not related to this block's field values. """ validation = super(StudioEditableXBlockMixin, self).validat...
Validates the state of this XBlock. Subclasses should override validate_field_data() to validate fields and override this only for validation not related to this block's field values.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L264-L273
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerXBlockMixin.render_children
def render_children(self, context, fragment, can_reorder=True, can_add=False): """ Renders the children of the module with HTML appropriate for Studio. If can_reorder is True, then the children will be rendered to support drag and drop. """ contents = [] child_context = ...
python
def render_children(self, context, fragment, can_reorder=True, can_add=False): """ Renders the children of the module with HTML appropriate for Studio. If can_reorder is True, then the children will be rendered to support drag and drop. """ contents = [] child_context = ...
Renders the children of the module with HTML appropriate for Studio. If can_reorder is True, then the children will be rendered to support drag and drop.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L283-L312
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerXBlockMixin.author_view
def author_view(self, context): """ Display a the studio editor when the user has clicked "View" to see the container view, otherwise just show the normal 'author_preview_view' or 'student_view' preview. """ root_xblock = context.get('root_xblock') if root_xblock and roo...
python
def author_view(self, context): """ Display a the studio editor when the user has clicked "View" to see the container view, otherwise just show the normal 'author_preview_view' or 'student_view' preview. """ root_xblock = context.get('root_xblock') if root_xblock and roo...
Display a the studio editor when the user has clicked "View" to see the container view, otherwise just show the normal 'author_preview_view' or 'student_view' preview.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L314-L324
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerXBlockMixin.author_edit_view
def author_edit_view(self, context): """ Child blocks can override this to control the view shown to authors in Studio when editing this block's children. """ fragment = Fragment() self.render_children(context, fragment, can_reorder=True, can_add=False) return fra...
python
def author_edit_view(self, context): """ Child blocks can override this to control the view shown to authors in Studio when editing this block's children. """ fragment = Fragment() self.render_children(context, fragment, can_reorder=True, can_add=False) return fra...
Child blocks can override this to control the view shown to authors in Studio when editing this block's children.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L326-L333
edx/xblock-utils
xblockutils/studio_editable.py
XBlockWithPreviewMixin.preview_view
def preview_view(self, context): """ Preview view - used by StudioContainerWithNestedXBlocksMixin to render nested xblocks in preview context. Default implementation uses author_view if available, otherwise falls back to student_view Child classes can override this method to control thei...
python
def preview_view(self, context): """ Preview view - used by StudioContainerWithNestedXBlocksMixin to render nested xblocks in preview context. Default implementation uses author_view if available, otherwise falls back to student_view Child classes can override this method to control thei...
Preview view - used by StudioContainerWithNestedXBlocksMixin to render nested xblocks in preview context. Default implementation uses author_view if available, otherwise falls back to student_view Child classes can override this method to control their presentation in preview context
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L405-L413
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerWithNestedXBlocksMixin.get_nested_blocks_spec
def get_nested_blocks_spec(self): """ Converts allowed_nested_blocks items to NestedXBlockSpec to provide common interface """ return [ block_spec if isinstance(block_spec, NestedXBlockSpec) else NestedXBlockSpec(block_spec) for block_spec in self.allowed_nested_b...
python
def get_nested_blocks_spec(self): """ Converts allowed_nested_blocks items to NestedXBlockSpec to provide common interface """ return [ block_spec if isinstance(block_spec, NestedXBlockSpec) else NestedXBlockSpec(block_spec) for block_spec in self.allowed_nested_b...
Converts allowed_nested_blocks items to NestedXBlockSpec to provide common interface
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L443-L450
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerWithNestedXBlocksMixin.author_edit_view
def author_edit_view(self, context): """ View for adding/editing nested blocks """ fragment = Fragment() if 'wrap_children' in context: fragment.add_content(context['wrap_children']['head']) self.render_children(context, fragment, can_reorder=True, can_add=F...
python
def author_edit_view(self, context): """ View for adding/editing nested blocks """ fragment = Fragment() if 'wrap_children' in context: fragment.add_content(context['wrap_children']['head']) self.render_children(context, fragment, can_reorder=True, can_add=F...
View for adding/editing nested blocks
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L452-L470
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerWithNestedXBlocksMixin.author_preview_view
def author_preview_view(self, context): """ View for previewing contents in studio. """ children_contents = [] fragment = Fragment() for child_id in self.children: child = self.runtime.get_block(child_id) child_fragment = self._render_child_fragme...
python
def author_preview_view(self, context): """ View for previewing contents in studio. """ children_contents = [] fragment = Fragment() for child_id in self.children: child = self.runtime.get_block(child_id) child_fragment = self._render_child_fragme...
View for previewing contents in studio.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L472-L491
edx/xblock-utils
xblockutils/studio_editable.py
StudioContainerWithNestedXBlocksMixin._render_child_fragment
def _render_child_fragment(self, child, context, view='student_view'): """ Helper method to overcome html block rendering quirks """ try: child_fragment = child.render(view, context) except NoSuchViewError: if child.scope_ids.block_type == 'html' and getat...
python
def _render_child_fragment(self, child, context, view='student_view'): """ Helper method to overcome html block rendering quirks """ try: child_fragment = child.render(view, context) except NoSuchViewError: if child.scope_ids.block_type == 'html' and getat...
Helper method to overcome html block rendering quirks
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/studio_editable.py#L493-L507
edx/xblock-utils
setup.py
package_data
def package_data(pkg, root_list): """Generic function to find package_data for `pkg` under `root`.""" data = [] for root in root_list: for dirname, _, files in os.walk(os.path.join(pkg, root)): for fname in files: data.append(os.path.relpath(os.path.join(dirname, fname), ...
python
def package_data(pkg, root_list): """Generic function to find package_data for `pkg` under `root`.""" data = [] for root in root_list: for dirname, _, files in os.walk(os.path.join(pkg, root)): for fname in files: data.append(os.path.relpath(os.path.join(dirname, fname), ...
Generic function to find package_data for `pkg` under `root`.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/setup.py#L29-L37
edx/xblock-utils
setup.py
load_requirements
def load_requirements(*requirements_paths): """ Load all requirements from the specified requirements files. Returns a list of requirement strings. """ requirements = set() for path in requirements_paths: requirements.update( line.split('#')[0].strip() for line in open(path)....
python
def load_requirements(*requirements_paths): """ Load all requirements from the specified requirements files. Returns a list of requirement strings. """ requirements = set() for path in requirements_paths: requirements.update( line.split('#')[0].strip() for line in open(path)....
Load all requirements from the specified requirements files. Returns a list of requirement strings.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/setup.py#L40-L51
edx/xblock-utils
setup.py
is_requirement
def is_requirement(line): """ Return True if the requirement line is a package requirement; that is, it is not blank, a comment, a URL, or an included file. """ return not ( line == '' or line.startswith('-r') or line.startswith('#') or line.startswith('-e') or ...
python
def is_requirement(line): """ Return True if the requirement line is a package requirement; that is, it is not blank, a comment, a URL, or an included file. """ return not ( line == '' or line.startswith('-r') or line.startswith('#') or line.startswith('-e') or ...
Return True if the requirement line is a package requirement; that is, it is not blank, a comment, a URL, or an included file.
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/setup.py#L54-L65
edx/xblock-utils
xblockutils/publish_event.py
PublishEventMixin.publish_event
def publish_event(self, data, suffix=''): """ AJAX handler to allow client-side code to publish a server-side event """ try: event_type = data.pop('event_type') except KeyError: return {'result': 'error', 'message': 'Missing event_type in JSON data'} ...
python
def publish_event(self, data, suffix=''): """ AJAX handler to allow client-side code to publish a server-side event """ try: event_type = data.pop('event_type') except KeyError: return {'result': 'error', 'message': 'Missing event_type in JSON data'} ...
AJAX handler to allow client-side code to publish a server-side event
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/publish_event.py#L37-L46
edx/xblock-utils
xblockutils/publish_event.py
PublishEventMixin.publish_event_from_dict
def publish_event_from_dict(self, event_type, data): """ Combine 'data' with self.additional_publish_event_data and publish an event """ for key, value in self.additional_publish_event_data.items(): if key in data: return {'result': 'error', 'message': 'Key sh...
python
def publish_event_from_dict(self, event_type, data): """ Combine 'data' with self.additional_publish_event_data and publish an event """ for key, value in self.additional_publish_event_data.items(): if key in data: return {'result': 'error', 'message': 'Key sh...
Combine 'data' with self.additional_publish_event_data and publish an event
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/publish_event.py#L48-L58
edx/xblock-utils
xblockutils/helpers.py
child_isinstance
def child_isinstance(block, child_id, block_class_or_mixin): """ Efficiently check if a child of an XBlock is an instance of the given class. Arguments: block -- the parent (or ancestor) of the child block in question child_id -- the usage key of the child block we are wondering about block_cla...
python
def child_isinstance(block, child_id, block_class_or_mixin): """ Efficiently check if a child of an XBlock is an instance of the given class. Arguments: block -- the parent (or ancestor) of the child block in question child_id -- the usage key of the child block we are wondering about block_cla...
Efficiently check if a child of an XBlock is an instance of the given class. Arguments: block -- the parent (or ancestor) of the child block in question child_id -- the usage key of the child block we are wondering about block_class_or_mixin -- We return true if block's child indentified by child_id is...
https://github.com/edx/xblock-utils/blob/2960666907d3eea1ed312fa87d811e78cd043702/xblockutils/helpers.py#L6-L25
Hrabal/TemPy
tempy/elements.py
Tag.attr
def attr(self, *args, **kwargs): """Add an attribute to the element""" kwargs.update({k: bool for k in args}) for key, value in kwargs.items(): if key == "klass": self.attrs["klass"].update(value.split()) elif key == "style": if isinstance(...
python
def attr(self, *args, **kwargs): """Add an attribute to the element""" kwargs.update({k: bool for k in args}) for key, value in kwargs.items(): if key == "klass": self.attrs["klass"].update(value.split()) elif key == "style": if isinstance(...
Add an attribute to the element
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L72-L86
Hrabal/TemPy
tempy/elements.py
Tag.remove_attr
def remove_attr(self, attr): """Removes an attribute.""" self._stable = False self.attrs.pop(attr, None) return self
python
def remove_attr(self, attr): """Removes an attribute.""" self._stable = False self.attrs.pop(attr, None) return self
Removes an attribute.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L88-L92
Hrabal/TemPy
tempy/elements.py
Tag.render_attrs
def render_attrs(self): """Renders the tag's attributes using the formats and performing special attributes name substitution.""" ret = [] for k, v in self.attrs.items(): if v: if v is bool: ret.append(" %s" % self._SPECIAL_ATTRS.get(k, k)) ...
python
def render_attrs(self): """Renders the tag's attributes using the formats and performing special attributes name substitution.""" ret = [] for k, v in self.attrs.items(): if v: if v is bool: ret.append(" %s" % self._SPECIAL_ATTRS.get(k, k)) ...
Renders the tag's attributes using the formats and performing special attributes name substitution.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L94-L105
Hrabal/TemPy
tempy/elements.py
Tag.toggle_class
def toggle_class(self, csscl): """Same as jQuery's toggleClass function. It toggles the css class on this element.""" self._stable = False action = ("add", "remove")[self.has_class(csscl)] return getattr(self.attrs["klass"], action)(csscl)
python
def toggle_class(self, csscl): """Same as jQuery's toggleClass function. It toggles the css class on this element.""" self._stable = False action = ("add", "remove")[self.has_class(csscl)] return getattr(self.attrs["klass"], action)(csscl)
Same as jQuery's toggleClass function. It toggles the css class on this element.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L137-L141
Hrabal/TemPy
tempy/elements.py
Tag.add_class
def add_class(self, cssclass): """Adds a css class to this element.""" if self.has_class(cssclass): return self return self.toggle_class(cssclass)
python
def add_class(self, cssclass): """Adds a css class to this element.""" if self.has_class(cssclass): return self return self.toggle_class(cssclass)
Adds a css class to this element.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L143-L147
Hrabal/TemPy
tempy/elements.py
Tag.remove_class
def remove_class(self, cssclass): """Removes the given class from this element.""" if not self.has_class(cssclass): return self return self.toggle_class(cssclass)
python
def remove_class(self, cssclass): """Removes the given class from this element.""" if not self.has_class(cssclass): return self return self.toggle_class(cssclass)
Removes the given class from this element.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L149-L153
Hrabal/TemPy
tempy/elements.py
Tag.css
def css(self, *props, **kwprops): """Adds css properties to this element.""" self._stable = False styles = {} if props: if len(props) == 1 and isinstance(props[0], Mapping): styles = props[0] else: raise WrongContentError(self, prop...
python
def css(self, *props, **kwprops): """Adds css properties to this element.""" self._stable = False styles = {} if props: if len(props) == 1 and isinstance(props[0], Mapping): styles = props[0] else: raise WrongContentError(self, prop...
Adds css properties to this element.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L155-L168
Hrabal/TemPy
tempy/elements.py
Tag.show
def show(self, display=None): """Removes the display style attribute. If a display type is provided """ self._stable = False if not display: self.attrs["style"].pop("display") else: self.attrs["style"]["display"] = display return self
python
def show(self, display=None): """Removes the display style attribute. If a display type is provided """ self._stable = False if not display: self.attrs["style"].pop("display") else: self.attrs["style"]["display"] = display return self
Removes the display style attribute. If a display type is provided
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L176-L184
Hrabal/TemPy
tempy/elements.py
Tag.toggle
def toggle(self): """Same as jQuery's toggle, toggles the display attribute of this element.""" self._stable = False return self.show() if self.attrs["style"]["display"] == "none" else self.hide()
python
def toggle(self): """Same as jQuery's toggle, toggles the display attribute of this element.""" self._stable = False return self.show() if self.attrs["style"]["display"] == "none" else self.hide()
Same as jQuery's toggle, toggles the display attribute of this element.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L186-L189
Hrabal/TemPy
tempy/elements.py
Tag.text
def text(self): """Renders the contents inside this element, without html tags.""" texts = [] for child in self.childs: if isinstance(child, Tag): texts.append(child.text()) elif isinstance(child, Content): texts.append(child.render()) ...
python
def text(self): """Renders the contents inside this element, without html tags.""" texts = [] for child in self.childs: if isinstance(child, Tag): texts.append(child.text()) elif isinstance(child, Content): texts.append(child.render()) ...
Renders the contents inside this element, without html tags.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L195-L205
Hrabal/TemPy
tempy/elements.py
Tag.render
def render(self, *args, **kwargs): """Renders the element and all his childrens.""" # args kwargs API provided for last minute content injection # self._reverse_mro_func('pre_render') pretty = kwargs.pop("pretty", False) if pretty and self._stable != "pretty": self._s...
python
def render(self, *args, **kwargs): """Renders the element and all his childrens.""" # args kwargs API provided for last minute content injection # self._reverse_mro_func('pre_render') pretty = kwargs.pop("pretty", False) if pretty and self._stable != "pretty": self._s...
Renders the element and all his childrens.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/elements.py#L207-L245
Hrabal/TemPy
tempy/t.py
TempyParser._make_tempy_tag
def _make_tempy_tag(self, tag, attrs, void): """Searches in tempy.tags for the correct tag to use, if does not exists uses the TempyFactory to create a custom tag.""" tempy_tag_cls = getattr(self.tempy_tags, tag.title(), None) if not tempy_tag_cls: unknow_maker = [self.unknow...
python
def _make_tempy_tag(self, tag, attrs, void): """Searches in tempy.tags for the correct tag to use, if does not exists uses the TempyFactory to create a custom tag.""" tempy_tag_cls = getattr(self.tempy_tags, tag.title(), None) if not tempy_tag_cls: unknow_maker = [self.unknow...
Searches in tempy.tags for the correct tag to use, if does not exists uses the TempyFactory to create a custom tag.
https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/t.py#L33-L49