code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def getUsersProfiles(self) -> dict[str, str] | None: """Returns the list of user profiles (from registry) in a dict Each subkey of HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList is a user SID, and the ProfileImagePath value inside is the path to the user's profile :return...
Returns the list of user profiles (from registry) in a dict Each subkey of HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList is a user SID, and the ProfileImagePath value inside is the path to the user's profile :return: dict of user_sid: path_to_profile
getUsersProfiles
python
zblurx/dploot
dploot/lib/smb.py
https://github.com/zblurx/dploot/blob/master/dploot/lib/smb.py
MIT
def _create_clone_schema_function(self): """ Creates a postgres function `clone_schema` that copies a schema and its contents. Will replace any existing `clone_schema` functions owned by the `postgres` superuser. """ cursor = connection.cursor() db_user = setting...
Creates a postgres function `clone_schema` that copies a schema and its contents. Will replace any existing `clone_schema` functions owned by the `postgres` superuser.
_create_clone_schema_function
python
django-tenants/django-tenants
django_tenants/clone.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/clone.py
MIT
def clone_schema( self, base_schema_name, new_schema_name, clone_mode="DATA", set_connection=True ): """ Creates a new schema `new_schema_name` as a clone of an existing schema `old_schema_name`. """ if set_connection: connection.set_schema_to_public() ...
Creates a new schema `new_schema_name` as a clone of an existing schema `old_schema_name`.
clone_schema
python
django-tenants/django-tenants
django_tenants/clone.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/clone.py
MIT
def __enter__(self): """ Syntax sugar which helps in celery tasks, cron jobs, and other scripts Usage: with Tenant.objects.get(schema_name='test') as tenant: # run some code in tenant test # run some code in previous tenant (public probably) """ ...
Syntax sugar which helps in celery tasks, cron jobs, and other scripts Usage: with Tenant.objects.get(schema_name='test') as tenant: # run some code in tenant test # run some code in previous tenant (public probably)
__enter__
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def pre_drop(self): """ This is a routine which you could override to backup the tenant schema before dropping. :return: """
This is a routine which you could override to backup the tenant schema before dropping. :return:
pre_drop
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def delete(self, force_drop=False, *args, **kwargs): """ Deletes this row. Drops the tenant's schema if the attribute auto_drop_schema set to True. """ self._drop_schema(force_drop) return super().delete(*args, **kwargs)
Deletes this row. Drops the tenant's schema if the attribute auto_drop_schema set to True.
delete
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def create_schema(self, check_if_exists=False, sync_schema=True, verbosity=1): """ Creates the schema 'schema_name' for this tenant. Optionally checks if the schema already exists before creating it. Returns true if the schema was created, false otherwise. "...
Creates the schema 'schema_name' for this tenant. Optionally checks if the schema already exists before creating it. Returns true if the schema was created, false otherwise.
create_schema
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def get_primary_domain(self): """ Returns the primary domain of the tenant """ try: domain = self.domains.get(is_primary=True) return domain except get_tenant_domain_model().DoesNotExist: return None
Returns the primary domain of the tenant
get_primary_domain
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def reverse(self, request, view_name): """ Returns the URL of this tenant. """ http_type = 'https://' if request.is_secure() else 'http://' domain = get_current_site(request).domain url = ''.join((http_type, self.schema_name, '.', domain, reverse(view_name))) r...
Returns the URL of this tenant.
reverse
python
django-tenants/django-tenants
django_tenants/models.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/models.py
MIT
def app_in_list(self, app_label, apps_list): """ Is 'app_label' present in 'apps_list'? apps_list is either settings.SHARED_APPS or settings.TENANT_APPS, a list of app names. We check the presence of the app's name or the full path to the apps's AppConfig class. ...
Is 'app_label' present in 'apps_list'? apps_list is either settings.SHARED_APPS or settings.TENANT_APPS, a list of app names. We check the presence of the app's name or the full path to the apps's AppConfig class. https://docs.djangoproject.com/en/1.8/ref/applications/...
app_in_list
python
django-tenants/django-tenants
django_tenants/routers.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/routers.py
MIT
def get_dynamic_tenant_prefixed_urlconf(urlconf, dynamic_path): """ Generates a new URLConf module with all patterns prefixed with tenant. """ from types import ModuleType from django.utils.module_loading import import_string class LazyURLConfModule(ModuleType): def __getattr__(self, at...
Generates a new URLConf module with all patterns prefixed with tenant.
get_dynamic_tenant_prefixed_urlconf
python
django-tenants/django-tenants
django_tenants/urlresolvers.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/urlresolvers.py
MIT
def get_subfolder_urlconf(tenant): """ Creates and returns a subfolder URLConf for tenant. """ if has_multi_type_tenants(): urlconf = get_tenant_types()[tenant.get_tenant_type()]['URLCONF'] else: urlconf = settings.ROOT_URLCONF dynamic_path = urlconf + "_dynamically_tenant_prefix...
Creates and returns a subfolder URLConf for tenant.
get_subfolder_urlconf
python
django-tenants/django-tenants
django_tenants/urlresolvers.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/urlresolvers.py
MIT
def get_tenant_type_choices(): """This is to allow a choice field for the type of tenant""" if not has_multi_type_tenants(): assert False, 'get_tenant_type_choices should only be used for multi type tenants' tenant_types = get_tenant_types() return [(k, k) for k in tenant_types.keys()]
This is to allow a choice field for the type of tenant
get_tenant_type_choices
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def get_creation_fakes_migrations(): """ If TENANT_CREATION_FAKES_MIGRATIONS, tenants will be created by cloning an existing schema specified by TENANT_CLONE_BASE. """ faked = getattr(settings, 'TENANT_CREATION_FAKES_MIGRATIONS', False) if faked: if not getattr(settings, 'TENANT_BASE_SCH...
If TENANT_CREATION_FAKES_MIGRATIONS, tenants will be created by cloning an existing schema specified by TENANT_CLONE_BASE.
get_creation_fakes_migrations
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def get_tenant_base_schema(): """ If TENANT_CREATION_FAKES_MIGRATIONS, tenants will be created by cloning an existing schema specified by TENANT_CLONE_BASE. """ schema = getattr(settings, 'TENANT_BASE_SCHEMA', False) if schema: if not getattr(settings, 'TENANT_CREATION_FAKES_MIGRATIONS',...
If TENANT_CREATION_FAKES_MIGRATIONS, tenants will be created by cloning an existing schema specified by TENANT_CLONE_BASE.
get_tenant_base_schema
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def remove_www(hostname): """ Removes www. from the beginning of the address. Only for routing purposes. www.test.com/login/ and test.com/login/ should find the same tenant. """ if hostname.startswith("www."): return hostname[4:] return hostname
Removes www. from the beginning of the address. Only for routing purposes. www.test.com/login/ and test.com/login/ should find the same tenant.
remove_www
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def schema_rename(tenant, new_schema_name, database=get_tenant_database_alias(), save=True): """ This renames a schema to a new name. It checks to see if it exists first """ from django_tenants.postgresql_backend.base import is_valid_schema_name _connection = connections[database] cursor = _conn...
This renames a schema to a new name. It checks to see if it exists first
schema_rename
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def parse_tenant_config_path(config_path): """ Convenience function for parsing django-tenants' path configuration strings. If the string contains '%s', then the current tenant's schema name will be inserted at that location. Otherwise the schema name will be appended to the end of the string. :pa...
Convenience function for parsing django-tenants' path configuration strings. If the string contains '%s', then the current tenant's schema name will be inserted at that location. Otherwise the schema name will be appended to the end of the string. :param config_path: A configuration path string that ...
parse_tenant_config_path
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def tenant_migration(*args, tenant_schema=True, public_schema=False): """ Decorator to control which schemas a data migration will execute on. :param tenant_schema: If True (default), the data migration will execute on the tenant schema(s). :param public_schema: If True, the data migration will exe...
Decorator to control which schemas a data migration will execute on. :param tenant_schema: If True (default), the data migration will execute on the tenant schema(s). :param public_schema: If True, the data migration will execute on the public schema. :return: None
tenant_migration
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def get_tenant(request): """This gets the tenant object from the request""" if hasattr(request, 'tenant'): return request.tenant return None
This gets the tenant object from the request
get_tenant
python
django-tenants/django-tenants
django_tenants/utils.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/utils.py
MIT
def listdir(self, path): """ More forgiving wrapper for parent class implementation that does not insist on each tenant having its own static files dir. """ try: return super().listdir(path) except FileNotFoundError: # Having static files for each ...
More forgiving wrapper for parent class implementation that does not insist on each tenant having its own static files dir.
listdir
python
django-tenants/django-tenants
django_tenants/files/storage.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/files/storage.py
MIT
def run_from_argv(self, argv): """ Changes the option_list to use the options from the wrapped command. """ # load the command object. if len(argv) <= 2: return no_public = "--no-public" in argv command_args = [argv[0]] ...
Changes the option_list to use the options from the wrapped command.
run_from_argv
python
django-tenants/django-tenants
django_tenants/management/commands/all_tenants_command.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/management/commands/all_tenants_command.py
MIT
def run_from_argv(self, argv): """ Changes the option_list to use the options from the wrapped command. Adds schema parameter to specify which schema will be used when executing the wrapped command. """ # load the command object. if len(argv) <= 2: ret...
Changes the option_list to use the options from the wrapped command. Adds schema parameter to specify which schema will be used when executing the wrapped command.
run_from_argv
python
django-tenants/django-tenants
django_tenants/management/commands/tenant_command.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/management/commands/tenant_command.py
MIT
def handle(self, *args, **options): """ Iterates a command over all registered schemata. """ if options['schema_name'] or self.schema_name: # options schema_name can override inherited schema_name schema_name = options['schema_name'] or self.schema_name ...
Iterates a command over all registered schemata.
handle
python
django-tenants/django-tenants
django_tenants/management/commands/__init__.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/management/commands/__init__.py
MIT
def get_domain_from_options_or_interactive(self, tenant, **options): """ Get the domain from the options or interactively if not provided in the options. """ _DomainModel = get_tenant_domain_model() all_domains = _DomainModel.objects.all() if not all_domains: ...
Get the domain from the options or interactively if not provided in the options.
get_domain_from_options_or_interactive
python
django-tenants/django-tenants
django_tenants/management/commands/__init__.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/management/commands/__init__.py
MIT
def no_tenant_found(self, request, hostname): """ What should happen if no tenant is found. This makes it easier if you want to override the default behavior """ if hasattr(settings, 'DEFAULT_NOT_FOUND_TENANT_VIEW'): view_path = settings.DEFAULT_NOT_FOUND_TENANT_VIEW view...
What should happen if no tenant is found. This makes it easier if you want to override the default behavior
no_tenant_found
python
django-tenants/django-tenants
django_tenants/middleware/main.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/middleware/main.py
MIT
def setup_url_routing(request, force_public=False): """ Sets the correct url conf based on the tenant :param request: :param force_public """ public_schema_name = get_public_schema_name() if has_multi_type_tenants(): tenant_types = get_tenant_types() ...
Sets the correct url conf based on the tenant :param request: :param force_public
setup_url_routing
python
django-tenants/django-tenants
django_tenants/middleware/main.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/middleware/main.py
MIT
def set_tenant(self, tenant, include_public=True): """ Main API method to current database schema, but it does not actually modify the db connection. """ self.tenant = tenant self.schema_name = tenant.schema_name self.include_public_schema = include_public ...
Main API method to current database schema, but it does not actually modify the db connection.
set_tenant
python
django-tenants/django-tenants
django_tenants/postgresql_backend/base.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/postgresql_backend/base.py
MIT
def _cursor(self, name=None): """ Here it happens. We hope every Django db operation using PostgreSQL must go through this to get the cursor handle. We change the path. """ if name: # Only supported and required by Django 1.11 (server-side cursor) cursor =...
Here it happens. We hope every Django db operation using PostgreSQL must go through this to get the cursor handle. We change the path.
_cursor
python
django-tenants/django-tenants
django_tenants/postgresql_backend/base.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/postgresql_backend/base.py
MIT
def locations(self): """ Lazy retrieval of list of locations with static files based on current tenant schema. :return: The list of static file dirs that have been configured for this tenant. """ if self._locations.get(connection.schema_name, None) is None: schema_loc...
Lazy retrieval of list of locations with static files based on current tenant schema. :return: The list of static file dirs that have been configured for this tenant.
locations
python
django-tenants/django-tenants
django_tenants/staticfiles/finders.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/staticfiles/finders.py
MIT
def storages(self): """ Lazy retrieval of list of storage handlers for the current tenant. :return: A ,a[ pf dir paths to an appropriate storage instance. """ if self._storages.get(connection.schema_name, None) is None: schema_storages = OrderedDict() for...
Lazy retrieval of list of storage handlers for the current tenant. :return: A ,a[ pf dir paths to an appropriate storage instance.
storages
python
django-tenants/django-tenants
django_tenants/staticfiles/finders.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/staticfiles/finders.py
MIT
def check(self, **kwargs): """ In addition to parent class' checks, also ensure that MULTITENANT_STATICFILES_DIRS is a tuple or a list. """ errors = super().check(**kwargs) multitenant_staticfiles_dirs = settings.MULTITENANT_STATICFILES_DIRS if not isinstance(mul...
In addition to parent class' checks, also ensure that MULTITENANT_STATICFILES_DIRS is a tuple or a list.
check
python
django-tenants/django-tenants
django_tenants/staticfiles/finders.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/staticfiles/finders.py
MIT
def dirs(self): """ Lazy retrieval of list of template directories based on current tenant schema. :return: The list of template file dirs that have been configured for this tenant. """ if self._dirs.get(connection.schema_name, None) is None: try: # Us...
Lazy retrieval of list of template directories based on current tenant schema. :return: The list of template file dirs that have been configured for this tenant.
dirs
python
django-tenants/django-tenants
django_tenants/template/loaders/filesystem.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/template/loaders/filesystem.py
MIT
def test_multi_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.tenant_domain) self.tm.process_request(request) self.assertEqual(...
Request path should not be altered.
test_multi_routing
python
django-tenants/django-tenants
django_tenants/tests/test_multi_types.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_multi_types.py
MIT
def test_tenant_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.tenant_domain) self.tm.process_request(request) self.assertEqual...
Request path should not be altered.
test_tenant_routing
python
django-tenants/django-tenants
django_tenants/tests/test_multi_types.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_multi_types.py
MIT
def test_public_schema_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.public_domain.domain) self.tm.process_request(request) se...
Request path should not be altered.
test_public_schema_routing
python
django-tenants/django-tenants
django_tenants/tests/test_multi_types.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_multi_types.py
MIT
def test_tenant_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.tenant_domain) self.tm.process_request(request) self.assertEqual...
Request path should not be altered.
test_tenant_routing
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_public_schema_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.public_domain.domain) self.tm.process_request(request) se...
Request path should not be altered.
test_public_schema_routing
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_tenant_routing(self): """ Request path should not be altered. """ request_url = '/clients/tenant.test.com/any/request/' request = self.factory.get('/clients/tenant.test.com/any/request/', HTTP_HOST=self.public_domain.domain) sel...
Request path should not be altered.
test_tenant_routing
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_public_schema_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/', HTTP_HOST=self.public_domain.domain) self.tsf.process_request(request) s...
Request path should not be altered.
test_public_schema_routing
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_missing_tenant(self): """ Request path should not be altered. """ request = self.factory.get('/clients/not-found/any/request/', HTTP_HOST=self.public_domain.domain) with self.assertRaises(self.tsf.TENANT_NOT_FOUND_EXCEPTION): ...
Request path should not be altered.
test_missing_tenant
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_subfolder_routing_without_prefix(self): """ Should raise ImproperlyConfigured if no sensible TENANT_SUBFOLDER_PREFIX is found in settings. """ settings.TENANT_SUBFOLDER_PREFIX = None with self.assertRaises(ImproperlyConfigured): TenantSubfolderMiddlew...
Should raise ImproperlyConfigured if no sensible TENANT_SUBFOLDER_PREFIX is found in settings.
test_subfolder_routing_without_prefix
python
django-tenants/django-tenants
django_tenants/tests/test_routes.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_routes.py
MIT
def test_tenant_routing(self): """ Request path should not be altered. """ request_url = '/clients/tenant.test.com/any/request/' request = self.factory.get('/clients/tenant.test.com/any/request/') self.tsf.process_request(request) self.assertEqual(request.path_in...
Request path should not be altered.
test_tenant_routing
python
django-tenants/django-tenants
django_tenants/tests/test_subfolder_case.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_subfolder_case.py
MIT
def test_public_schema_routing(self): """ Request path should not be altered. """ request_url = '/any/request/' request = self.factory.get('/any/request/') self.tsf.process_request(request) self.assertEqual(request.path_info, request_url) # request.tenan...
Request path should not be altered.
test_public_schema_routing
python
django-tenants/django-tenants
django_tenants/tests/test_subfolder_case.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_subfolder_case.py
MIT
def test_missing_tenant(self): """ Request path should not be altered. """ request = self.factory.get('/clients/not-found/any/request/') with self.assertRaises(self.tsf.TENANT_NOT_FOUND_EXCEPTION): self.tsf.process_request(request)
Request path should not be altered.
test_missing_tenant
python
django-tenants/django-tenants
django_tenants/tests/test_subfolder_case.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_subfolder_case.py
MIT
def catch_signal(signal): """ Catch django signal and return the mocked call. """ handler = mock.Mock() signal.connect(handler) yield handler signal.disconnect(handler)
Catch django signal and return the mocked call.
catch_signal
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_tenant_schema_is_created(self): """ When saving a tenant, it's schema should be created. """ tenant = get_tenant_model()(schema_name='test') tenant.save() domain = get_tenant_domain_model()(tenant=tenant, domain='something.test.com') domain.save() ...
When saving a tenant, it's schema should be created.
test_tenant_schema_is_created
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_tenant_schema_is_created_atomically(self): """ When saving a tenant, it's schema should be created. This should work in atomic transactions too. """ executor = get_executor() Tenant = get_tenant_model() schema_name = 'test' @transaction.atomic()...
When saving a tenant, it's schema should be created. This should work in atomic transactions too.
test_tenant_schema_is_created_atomically
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_non_auto_sync_tenant(self): """ When saving a tenant that has the flag auto_create_schema as False, the schema should not be created when saving the tenant. """ tenant = get_tenant_model()(schema_name='test') tenant.auto_create_schema = False tenant.save...
When saving a tenant that has the flag auto_create_schema as False, the schema should not be created when saving the tenant.
test_non_auto_sync_tenant
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_sync_tenant(self): """ When editing an existing tenant, all data should be kept. """ tenant = get_tenant_model()(schema_name='test') tenant.save() domain = get_tenant_domain_model()(tenant=tenant, domain='something.test.com') domain.save() # go ...
When editing an existing tenant, all data should be kept.
test_sync_tenant
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_switching_search_path(self): """ IMPORTANT: using schema_name with underscore here. See https://github.com/django-tenants/django-tenants/pull/829 """ tenant1 = get_tenant_model()(schema_name='tenant`1') tenant1.save() domain1 = get_tenant_domain_model()(...
IMPORTANT: using schema_name with underscore here. See https://github.com/django-tenants/django-tenants/pull/829
test_switching_search_path
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_tenant_schema_creation_with_special_chars(self): """Tests using special characters in schema name.""" schema_names = ('test-hyphen', 'test@at', 'test`backtick', 'country_BD') Client = get_tenant_model() for schema_name in schema_names: tenant = Client(schema_name=sc...
Tests using special characters in schema name.
test_tenant_schema_creation_with_special_chars
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_shared_apps_does_not_sync_tenant_apps(self): """ Tests that if an app is in SHARED_APPS, it does not get synced to the a tenant schema. """ shared_tables = self.get_tables_list_in_schema(get_public_schema_name()) self.assertEqual(2 + 6 + 1 + self.MIGRATION_TABLE_...
Tests that if an app is in SHARED_APPS, it does not get synced to the a tenant schema.
test_shared_apps_does_not_sync_tenant_apps
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_tenant_apps_does_not_sync_shared_apps(self): """ Tests that if an app is in TENANT_APPS, it does not get synced to the public schema. """ tenant = get_tenant_model()(schema_name='test') tenant.save() domain = get_tenant_domain_model()(tenant=tenant, doma...
Tests that if an app is in TENANT_APPS, it does not get synced to the public schema.
test_tenant_apps_does_not_sync_shared_apps
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_tenant_apps_and_shared_apps_can_have_the_same_apps(self): """ Tests that both SHARED_APPS and TENANT_APPS can have apps in common. In this case they should get synced to both tenant and public schemas. """ tenant = get_tenant_model()(schema_name='test') tenant.sa...
Tests that both SHARED_APPS and TENANT_APPS can have apps in common. In this case they should get synced to both tenant and public schemas.
test_tenant_apps_and_shared_apps_can_have_the_same_apps
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_content_types_is_not_mandatory(self): """ Tests that even if content types is in SHARED_APPS, it's not required in TENANT_APPS. """ tenant = get_tenant_model()(schema_name='test') tenant.save() domain = get_tenant_domain_model()(tenant=tenant, domain='som...
Tests that even if content types is in SHARED_APPS, it's not required in TENANT_APPS.
test_content_types_is_not_mandatory
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_cross_schema_constraint_gets_created(self): """ Tests that a foreign key constraint gets created even for cross schema references. """ sql = """ SELECT tc.constraint_name, tc.table_name, kcu.column_name, ccu.table_name AS foreign_table_name, ...
Tests that a foreign key constraint gets created even for cross schema references.
test_cross_schema_constraint_gets_created
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_direct_relation_to_public(self): """ Tests that a forward relationship through a foreign key to public from a model inside TENANT_APPS works. """ with tenant_context(self.tenant): self.assertEqual(User.objects.get(pk=self.user1.id), Model...
Tests that a forward relationship through a foreign key to public from a model inside TENANT_APPS works.
test_direct_relation_to_public
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_reverse_relation_to_public(self): """ Tests that a reverse relationship through a foreign keys to public from a model inside TENANT_APPS works. """ with tenant_context(self.tenant): users = User.objects.all().select_related().order_by('id') self.assertEqu...
Tests that a reverse relationship through a foreign keys to public from a model inside TENANT_APPS works.
test_reverse_relation_to_public
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_clone_schema_with_existing_records_and_add_new_records_to_resulting_schema(self): """ Exercises the scenario where the source schema contains records in a shared app which get cloned in the destination schema but the value of the PK column remains at 1 which causes duplicate key...
Exercises the scenario where the source schema contains records in a shared app which get cloned in the destination schema but the value of the PK column remains at 1 which causes duplicate key errors. See https://github.com/django-tenants/django-tenants/issues/831
test_clone_schema_with_existing_records_and_add_new_records_to_resulting_schema
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_signal_on_sync_shared(self): """ Public schema always gets migrated in the current process, even with executor multiprocessing. """ with catch_signal(schema_migrated) as handler_post, catch_signal(schema_pre_migration) as handler_pre: self.sync_shared() ...
Public schema always gets migrated in the current process, even with executor multiprocessing.
test_signal_on_sync_shared
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_signal_on_tenant_create(self): """ Since migrate gets called on creating of a tenant, check the signal gets sent. """ executor = get_executor() tenant = get_tenant_model()(schema_name='test') with catch_signal(schema_migrated) as handler_post, catch_sign...
Since migrate gets called on creating of a tenant, check the signal gets sent.
test_signal_on_tenant_create
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_signal_on_migrate_schemas(self): """ Check signals are sent on running of migrate_schemas. """ executor = get_executor() tenant = get_tenant_model()(schema_name='test') tenant.save() domain = get_tenant_domain_model()(tenant=tenant, domain='something.test...
Check signals are sent on running of migrate_schemas.
test_signal_on_migrate_schemas
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def test_migrate_schemas_order(self): """ Test the migrate schemas is determined by TENANT_MIGRATION_ORDER. """ executor = get_executor() if executor.codename != "standard": # can only test in standard executor return tenant1 = get_tenant_model().objects.cre...
Test the migrate schemas is determined by TENANT_MIGRATION_ORDER.
test_migrate_schemas_order
python
django-tenants/django-tenants
django_tenants/tests/test_tenants.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_tenants.py
MIT
def reverser_func(self, name, tenant): """ Reverses `name` in the urlconf returned from `tenant`. """ urlconf_path = get_subfolder_urlconf(tenant) urlconf = import_module(urlconf_path) reverse_response = reverse(name, urlconf=urlconf) ...
Reverses `name` in the urlconf returned from `tenant`.
reverser_func
python
django-tenants/django-tenants
django_tenants/tests/test_urlresolvers.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/test_urlresolvers.py
MIT
def test_file_path(self): """ File storage returns the full path of a file """ self.assertFalse(self.storage.exists("test.file")) f = ContentFile("custom contents") f_name = self.storage.save("test.file", f) self.assertEqual( os.path.join(self.temp_d...
File storage returns the full path of a file
test_file_path
python
django-tenants/django-tenants
django_tenants/tests/files/test_storage.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/files/test_storage.py
MIT
def test_file_save_with_path(self): """ Saving a pathname should create intermediate directories as necessary. """ self.assertFalse(self.storage.exists("path/to")) self.storage.save("path/to/test.file", ContentFile("file saved with path")) self.assertTrue(self.storage.ex...
Saving a pathname should create intermediate directories as necessary.
test_file_save_with_path
python
django-tenants/django-tenants
django_tenants/tests/files/test_storage.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/files/test_storage.py
MIT
def test_file_url(self): """ File storage returns a url to access a given file from the Web. """ self.assertEqual( self.storage.url("test.file"), self.storage.base_url + "test.file" ) # should encode special chars except ~!*()' # like encodeURICompone...
File storage returns a url to access a given file from the Web.
test_file_url
python
django-tenants/django-tenants
django_tenants/tests/files/test_storage.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/files/test_storage.py
MIT
def test_base_url(self): """ File storage returns a url even when its base_url is unset or modified. """ self.storage._base_url = None # This standard Django test is no longer relevant since we don't make use of @cached_property # with self.assertRaises(ValueError): ...
File storage returns a url even when its base_url is unset or modified.
test_base_url
python
django-tenants/django-tenants
django_tenants/tests/files/test_storage.py
https://github.com/django-tenants/django-tenants/blob/master/django_tenants/tests/files/test_storage.py
MIT
def reverse(self, request, view_name): """ If you have a different implementation of reverse from what the Django-Tenants library uses (A.k.a. Sites Framework) then you can write your own override here. """ # Write your own custom code else use existing code. retu...
If you have a different implementation of reverse from what the Django-Tenants library uses (A.k.a. Sites Framework) then you can write your own override here.
reverse
python
django-tenants/django-tenants
dts_test_project/customers/models.py
https://github.com/django-tenants/django-tenants/blob/master/dts_test_project/customers/models.py
MIT
def pytest_collect_file(parent, path): """Collect all file suitable for use in tests""" if path.basename == "README.md": return ReadmeFile.from_parent(parent, path=Path(path))
Collect all file suitable for use in tests
pytest_collect_file
python
zedr/clean-code-python
conftest.py
https://github.com/zedr/clean-code-python/blob/master/conftest.py
MIT
def _with_patched_sleep(func, *args, **kwargs): """Patch the sleep function so that it does nothing""" _sleep = time.sleep time.sleep = lambda *args: None try: return func(*args, **kwargs) finally: time.sleep = _sleep
Patch the sleep function so that it does nothing
_with_patched_sleep
python
zedr/clean-code-python
conftest.py
https://github.com/zedr/clean-code-python/blob/master/conftest.py
MIT
def repr_failure(self, excinfo, **kwargs): """ called when self.runtest() raises an exception. """ return ( f"Code snippet {self.name} raised an error: {excinfo.value}. " f"The executed code was: {self.spec}" )
called when self.runtest() raises an exception.
repr_failure
python
zedr/clean-code-python
conftest.py
https://github.com/zedr/clean-code-python/blob/master/conftest.py
MIT
def set_prefs(prefs): """This function is called before opening the project""" # Specify which files and folders to ignore in the project. # Changes to ignored resources are not added to the history and # VCSs. Also they are not returned in `Project.get_files()`. # Note that ``?`` and ``*`` match ...
This function is called before opening the project
set_prefs
python
pedroCabrera/PyFlow
.vscode/.ropeproject/config.py
https://github.com/pedroCabrera/PyFlow/blob/master/.vscode/.ropeproject/config.py
Apache-2.0
def getTempDirectory(self): """Returns unique temp directory for application instance. This folder and all its content will be removed from disc on application shutdown. """ if self.currentTempDir == "": # create app folder in documents # random string used for c...
Returns unique temp directory for application instance. This folder and all its content will be removed from disc on application shutdown.
getTempDirectory
python
pedroCabrera/PyFlow
PyFlow/App.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/App.py
Apache-2.0
def getTempDirectory(self): """Returns unique temp directory for application instance. This folder and all it's content will be removed from disc on application shutdown. """ if self.currentTempDir == "": # create app folder in documents # random string used for ...
Returns unique temp directory for application instance. This folder and all it's content will be removed from disc on application shutdown.
getTempDirectory
python
pedroCabrera/PyFlow
PyFlow/AppMDI.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/AppMDI.py
Apache-2.0
def fetchPackageNames(graphJson): """Parses serialized graph and returns all package names it uses :param graphJson: Serialized graph :type graphJson: dict :rtyoe: list(str) """ packages = set() def worker(graphData): for node in graphData["nodes"]: packages.add(node["p...
Parses serialized graph and returns all package names it uses :param graphJson: Serialized graph :type graphJson: dict :rtyoe: list(str)
fetchPackageNames
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def validateGraphDataPackages(graphData, missedPackages=None): """Checks if packages used in serialized data accessible Missed packages will be added to output set :param graphData: Serialized graph :type graphData: dict :param missedPackages: Package names that missed :type missedPackages: se...
Checks if packages used in serialized data accessible Missed packages will be added to output set :param graphData: Serialized graph :type graphData: dict :param missedPackages: Package names that missed :type missedPackages: set :rtype: bool
validateGraphDataPackages
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def mapRangeClamped(Value, InRangeA, InRangeB, OutRangeA, OutRangeB): """Returns Value mapped from one range into another where the Value is clamped to the Input Range. (e.g. 0.5 normalized from the range 0->1 to 0->50 would result in 25) """ ClampedPct = clamp(GetRangePct(InRangeA, InRangeB, Value), 0...
Returns Value mapped from one range into another where the Value is clamped to the Input Range. (e.g. 0.5 normalized from the range 0->1 to 0->50 would result in 25)
mapRangeClamped
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def findGoodId(ids): """ Finds good minimum unique int from iterable. Starting from 1 :param ids: a collection of occupied ids :type ids: list|set|tuple :returns: Unique Id :rtype: int """ if len(ids) == 0: return 1 ids = sorted(set(ids)) lastID = min(ids) if lastI...
Finds good minimum unique int from iterable. Starting from 1 :param ids: a collection of occupied ids :type ids: list|set|tuple :returns: Unique Id :rtype: int
findGoodId
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def wrapStringToFunctionDef(functionName, scriptString, kwargs=None): """Generates function string which then can be compiled and executed Example: :: wrapStringToFunctionDef('test', 'print(a)', {'a': 5}) Will produce following function: :: def test(a=5): print(a) ...
Generates function string which then can be compiled and executed Example: :: wrapStringToFunctionDef('test', 'print(a)', {'a': 5}) Will produce following function: :: def test(a=5): print(a)
wrapStringToFunctionDef
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def cycleCheck(src, dst): """Check for cycle connected nodes :param src: hand side pin :type src: :class:`PyFlow.Core.PinBase.PinBase` :param dst: hand side pin :type dst: :class:`PyFlow.Core.PinBase.PinBase` :returns: True if cycle deleted :rtype: bool """ if src.direction == PinDi...
Check for cycle connected nodes :param src: hand side pin :type src: :class:`PyFlow.Core.PinBase.PinBase` :param dst: hand side pin :type dst: :class:`PyFlow.Core.PinBase.PinBase` :returns: True if cycle deleted :rtype: bool
cycleCheck
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def arePinsConnected(src, dst): """Checks if two pins are connected .. note:: Pins can be passed in any order if **src** pin is :py:class:`PyFlow.Core.Common.PinDirection`, they will be swapped :param src: left hand side pin :type src: :py:class:`PyFlow.Core.PinBase.PinBase` :param dst: right hand...
Checks if two pins are connected .. note:: Pins can be passed in any order if **src** pin is :py:class:`PyFlow.Core.Common.PinDirection`, they will be swapped :param src: left hand side pin :type src: :py:class:`PyFlow.Core.PinBase.PinBase` :param dst: right hand side pin :type dst: :py:class:`PyF...
arePinsConnected
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def getConnectedPins(pin): """Find all connected Pins to input Pin :param pin: Pin to search connected pins :type pin: :py:class:`PyFlow.Core.PinBase.PinBase` :returns: Set of connected pins :rtype: set(:py:class:`PyFlow.Core.PinBase.PinBase`) """ result = set() if pin.direction == PinD...
Find all connected Pins to input Pin :param pin: Pin to search connected pins :type pin: :py:class:`PyFlow.Core.PinBase.PinBase` :returns: Set of connected pins :rtype: set(:py:class:`PyFlow.Core.PinBase.PinBase`)
getConnectedPins
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def canConnectPins(src, dst): """**Very important fundamental function, it checks if connection between two pins is possible** :param src: Source pin to connect :type src: :py:class:`PyFlow.Core.PinBase.PinBase` :param dst: Destination pin to connect :type dst: :py:class:`PyFlow.Core.PinBase.PinBas...
**Very important fundamental function, it checks if connection between two pins is possible** :param src: Source pin to connect :type src: :py:class:`PyFlow.Core.PinBase.PinBase` :param dst: Destination pin to connect :type dst: :py:class:`PyFlow.Core.PinBase.PinBase` :returns: True if connection c...
canConnectPins
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def connectPins(src, dst): """**Connects two pins** These are the rules how pins connect: * Input value pins can have one output connection if :py:class:`PyFlow.Core.Common.PinOptions.AllowMultipleConnections` flag is disabled * Output value pins can have any number of connections * Input execs ca...
**Connects two pins** These are the rules how pins connect: * Input value pins can have one output connection if :py:class:`PyFlow.Core.Common.PinOptions.AllowMultipleConnections` flag is disabled * Output value pins can have any number of connections * Input execs can have any number of connections ...
connectPins
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def connectPinsByIndexes(lhsNode=None, lhsOutPinIndex=0, rhsNode=None, rhsInPinIndex=0): """Connects pins regardless name. This function uses pin locations on node. Top most pin have position index 1, pin below - 2 etc. :param lhsNode: Left hand side node :type lhsNode: :class:`~PyFlow.Core.NodeBase.N...
Connects pins regardless name. This function uses pin locations on node. Top most pin have position index 1, pin below - 2 etc. :param lhsNode: Left hand side node :type lhsNode: :class:`~PyFlow.Core.NodeBase.NodeBase` :param lhsOutPinIndex: Out pin position on left hand side node :type lhsOutPinI...
connectPinsByIndexes
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def traverseConstrainedPins(startFrom, callback): """Iterate over constrained and connected pins Iterates over all constrained chained pins of type :class:`Any <PyFlow.Packages.PyFlowBase.Pins.AnyPin.AnyPin>` and passes pin into callback function. Callback will be executed once for every pin :param startF...
Iterate over constrained and connected pins Iterates over all constrained chained pins of type :class:`Any <PyFlow.Packages.PyFlowBase.Pins.AnyPin.AnyPin>` and passes pin into callback function. Callback will be executed once for every pin :param startFrom: First pin to start Iteration :type startFrom: :c...
traverseConstrainedPins
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def disconnectPins(src, dst): """Disconnects two pins :param src: left hand side pin :type src: :py:class:`~PyFlow.Core.PinBase.PinBase` :param dst: right hand side pin :type dst: :py:class:`~PyFlow.Core.PinBase.PinBase` :returns: True if disconnection success :rtype: bool """ if ar...
Disconnects two pins :param src: left hand side pin :type src: :py:class:`~PyFlow.Core.PinBase.PinBase` :param dst: right hand side pin :type dst: :py:class:`~PyFlow.Core.PinBase.PinBase` :returns: True if disconnection success :rtype: bool
disconnectPins
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def push(start_from): """Marks dirty all ports from start to the right this part of graph will be recomputed every tick :param start_from: pin from which recursion begins :type start_from: :py:class:`~PyFlow.Core.PinBase.PinBase` """ #print("push", start_from.name, start_from.owningNode().name...
Marks dirty all ports from start to the right this part of graph will be recomputed every tick :param start_from: pin from which recursion begins :type start_from: :py:class:`~PyFlow.Core.PinBase.PinBase`
push
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def extractDigitsFromEndOfString(string): """Get digits at end of a string Example: >>> nums = extractDigitsFromEndOfString("h3ello154") >>> print(nums, type(nums)) >>> 154 <class 'int'> :param string: Input numbered string :type string: str :returns: Numbers in the final of the strin...
Get digits at end of a string Example: >>> nums = extractDigitsFromEndOfString("h3ello154") >>> print(nums, type(nums)) >>> 154 <class 'int'> :param string: Input numbered string :type string: str :returns: Numbers in the final of the string :rtype: int
extractDigitsFromEndOfString
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def getUniqNameFromList(existingNames, name): """Create unique name Iterates over **existingNames** and extracts the end digits to find a new unique id :param existingNames: List or set of strings where to search for existing indexes :type existingNames: list[str]|set[str] :param name: Name to obt...
Create unique name Iterates over **existingNames** and extracts the end digits to find a new unique id :param existingNames: List or set of strings where to search for existing indexes :type existingNames: list[str]|set[str] :param name: Name to obtain a unique version from :type name: str :re...
getUniqNameFromList
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def __init__(self, keyType, valueType="AnyPin", inp=None): """ :param keyType: Key dataType :param valueType: value dataType, defaults to None :type valueType: optional :param inp: Construct from another dict, defaults to {} :type inp: dict, optional """ i...
:param keyType: Key dataType :param valueType: value dataType, defaults to None :type valueType: optional :param inp: Construct from another dict, defaults to {} :type inp: dict, optional
__init__
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def __setitem__(self, key, item): """Re implements Python Dict __setitem__ to only allow Typed Keys. Will throw an Exception if non-Valid KeyType """ if type(key) == self.getClassFromType(self.keyType): super(PFDict, self).__setitem__(key, item) else: rai...
Re implements Python Dict __setitem__ to only allow Typed Keys. Will throw an Exception if non-Valid KeyType
__setitem__
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def getClassFromType(pinType): """ Gets the internal data structure for a defined pin type :param pinType: pinType Name :type pinType: class or None """ pin = findPinClassByType(pinType) if pin: pinClass = pin.internalDataStructure() retur...
Gets the internal data structure for a defined pin type :param pinType: pinType Name :type pinType: class or None
getClassFromType
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def findStructFromValue(value): """Finds :class:`~PyFlow.Core.Common.StructureType` from value :param value: input value to find structure. :returns: Structure Type for input value :rtype: :class:`~PyFlow.Core.Common.StructureType` """ if isinstance(value, list): return StructureType.A...
Finds :class:`~PyFlow.Core.Common.StructureType` from value :param value: input value to find structure. :returns: Structure Type for input value :rtype: :class:`~PyFlow.Core.Common.StructureType`
findStructFromValue
python
pedroCabrera/PyFlow
PyFlow/Core/Common.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/Common.py
Apache-2.0
def depth(self): """Returns depth level of this graph :rtype: int """ result = 1 parent = self._parentGraph while parent is not None: result += 1 parent = parent.parentGraph return result
Returns depth level of this graph :rtype: int
depth
python
pedroCabrera/PyFlow
PyFlow/Core/GraphBase.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/GraphBase.py
Apache-2.0
def getVarList(self): """return list of variables from active graph :rtype: list(:class:`~PyFlow.Core.Variable.Variable`) """ result = list(self._vars.values()) parent = self._parentGraph while parent is not None: result += list(parent._vars.values()) ...
return list of variables from active graph :rtype: list(:class:`~PyFlow.Core.Variable.Variable`)
getVarList
python
pedroCabrera/PyFlow
PyFlow/Core/GraphBase.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/GraphBase.py
Apache-2.0
def serialize(self, *args, **kwargs): """Returns serialized representation of this graph :rtype: dict """ result = { "name": self.name, "category": self.category, "vars": [v.serialize() for v in self._vars.values()], "nodes": [n.serialize(...
Returns serialized representation of this graph :rtype: dict
serialize
python
pedroCabrera/PyFlow
PyFlow/Core/GraphBase.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/GraphBase.py
Apache-2.0
def populateFromJson(self, jsonData): """Populates itself from serialized data :param jsonData: serialized graph :type jsonData: dict """ self.clear() self.name = self.graphManager.getUniqGraphName(jsonData["name"]) self.category = jsonData["category"] se...
Populates itself from serialized data :param jsonData: serialized graph :type jsonData: dict
populateFromJson
python
pedroCabrera/PyFlow
PyFlow/Core/GraphBase.py
https://github.com/pedroCabrera/PyFlow/blob/master/PyFlow/Core/GraphBase.py
Apache-2.0