from pathlib import Path

p = Path("/home/shquier/easyconf.net/easychair/app/services/WorkflowDictionary.php")

txt = p.read_text(encoding="utf-8", errors="ignore")

old_stages = """public const STAGES = [

        'submission',

        'screening',

        'review',

        'revision',

        'decision',

        'production',

        'issue',

        'published'

    ];"""

new_stages = """public const STAGES = [

        self::STAGE_SUBMISSION,

        self::STAGE_SCREENING,

        self::STAGE_REVIEW,

        self::STAGE_REVISION,

        self::STAGE_DECISION,

        self::STAGE_PRODUCTION,

        self::STAGE_ISSUE,

        self::STAGE_PUBLISHED

    ];"""

old_status = """public const STATUS = [

        'submitted',

        'screening',

        'under_review',

        'revision_required',

        'accepted',

        'rejected',

        'production',

        'assigned_to_issue',

        'published'

    ];"""

new_status = """public const STATUS = [

        self::STATUS_SUBMITTED,

        self::STATUS_SCREENING,

        self::STATUS_UNDER_REVIEW,

        self::STATUS_REVISION_REQUIRED,

        self::STATUS_ACCEPTED,

        self::STATUS_REJECTED,

        self::STATUS_PRODUCTION,

        self::STATUS_ASSIGNED_TO_ISSUE,

        self::STATUS_PUBLISHED

    ];"""

txt = txt.replace(old_stages, new_stages)
txt = txt.replace(old_status, new_status)

p.write_text(txt, encoding="utf-8")

print("Pack2411 applied.")
