Skip to content

commands.utils

Overview

Utilities for group migration management commands.

call_management_command

Run args through Django's call_command, capturing its output.

command is the BaseCommand instance invoking this (needs .dry_run, .style, .stdout). A trailing --dry-run is appended automatically when command.dry_run is set and the command being run is makemigrations. Exits the process with status 2 if the command wrote to stderr.

Signature

call_management_command(command, args)

Parameters

NameTypeRequiredDescription
commandyes
argsyes

Source

server/vueda/user/management/commands/utils.py:82

get_matching_record

Return GroupChange.pk if a record matching this change exists, None otherwise.

Signature

get_matching_record(change, group_change_model)

Parameters

NameTypeRequiredDescription
changeyes
group_change_modelyes

Source

server/vueda/user/management/commands/utils.py:33

has_direct_runpython_import

Return True if lines imports RunPython directly, e.g. from django.db.migrations import RunPython, rather than only accessing it via migrations.RunPython.

lines is a list of strings, as returned by readlines(). Only module-level from ... import statements are considered, so a RunPython import nested inside a copied function source is never matched.

Signature

has_direct_runpython_import(lines)

Parameters

NameTypeRequiredDescription
linesyes

Source

server/vueda/user/management/commands/utils.py:66

locate_empty_migration_slots

Locate the line numbers of the key components of a freshly generated, empty migration.

lines is a list of strings, as returned by readlines(), for a migration file created while migrations.Migration.operations was forced to a known, findable shape (two RunPython calls using dict/type and str/int as placeholder code/reverse_code values). Returns a dict of 0-based line numbers: class_index (the class Migration line), dependencies_index (the dependencies = [...] assignment), import_start/import_end (the import block), and the four placeholder keyword-value locations (p_forwards_index, p_reverse_index, forwards_index, reverse_index). Raises RuntimeError if any of them can't be found, e.g. because Django changed the shape of the empty-migration template it emits.

Signature

locate_empty_migration_slots(lines)

Parameters

NameTypeRequiredDescription
linesyes

Source

server/vueda/user/management/commands/utils.py:164

Source

server/vueda/user/management/commands/utils.py

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2