""" Constants that are relevant to all of Open edX """ # These are standard regexes for pulling out info like course_ids, usage_ids, etc. # They are used so that URLs with deprecated-format strings still work. # Note: these intentionally greedily grab all chars up to the next slash includingny pluses # DHM: I really wanted to ensure the separators were the same (+ or /) but all patts tried had # too many inadvertent side effects :-( COURSE_KEY_PATTERN = r'(?P[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)' COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id') COURSE_KEY_REGEX = COURSE_KEY_PATTERN.replace('P', ':') COURSE_PUBLISHED = 'published' COURSE_UNPUBLISHED = 'unpublished' ASSET_KEY_PATTERN = r'(?P(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' USAGE_KEY_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' USAGE_ID_PATTERN = USAGE_KEY_PATTERN.replace('usage_key_string', 'usage_id')