Add overriding for particular URLs. Add files overriding support.
This commit is contained in:
		@ -63,7 +63,7 @@ logger = logging.getLogger(__name__)
 | 
			
		||||
# * Add a 'additional files' config, like for installing brushes and such as part of the package. We'd have to patch
 | 
			
		||||
#   the appropirate meson files to do it.
 | 
			
		||||
# ** we might want to allow color vs. symbolic icons
 | 
			
		||||
# * impliment versioning somehow ?
 | 
			
		||||
# * impliment versioning somehow ? fill in appropirate version variables as needed.
 | 
			
		||||
# * Fixing various urls, dialogs, etc. (also the text wiggle in about, basically sort of bury the original stuff)
 | 
			
		||||
# * We should fix the README, like make a README generated
 | 
			
		||||
# * We should fix help menu
 | 
			
		||||
@ -158,6 +158,23 @@ def heckimp(args: Sequence[str]):
 | 
			
		||||
    else:
 | 
			
		||||
        shadow = ANNULUS
 | 
			
		||||
 | 
			
		||||
    tutorialurl = inconfig['url']
 | 
			
		||||
    if 'tutorialurl' in inconfig:
 | 
			
		||||
        tutorialurl = inconfig['tutorialurl']
 | 
			
		||||
 | 
			
		||||
    docsurl = inconfig['url']
 | 
			
		||||
    if 'docsurl' in inconfig:
 | 
			
		||||
        docsurl = inconfig['docsurl']
 | 
			
		||||
 | 
			
		||||
    contriburl = inconfig['url']
 | 
			
		||||
    if 'contriburl' in inconfig:
 | 
			
		||||
        contriburl = inconfig['contriburl']
 | 
			
		||||
 | 
			
		||||
    donateurl = inconfig['url']
 | 
			
		||||
    if 'donateurl' in inconfig:
 | 
			
		||||
        donateurl = inconfig['donateurl']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    derivedconfig={
 | 
			
		||||
        # Derived variables from config
 | 
			
		||||
        "longname": inconfig['name'].upper(),
 | 
			
		||||
@ -167,6 +184,10 @@ def heckimp(args: Sequence[str]):
 | 
			
		||||
        "ufilename": inconfig['name'].upper(),
 | 
			
		||||
        "backdomain": reverse_domain(inconfig['url']),
 | 
			
		||||
        "baseurl": inconfig['url'],
 | 
			
		||||
        "tutorialurl": tutorialurl,
 | 
			
		||||
        "docsurl": docsurl,
 | 
			
		||||
        "contriburl": contriburl,
 | 
			
		||||
        "donateurl": donateurl,
 | 
			
		||||
        "copyright": inconfig['copyright'],
 | 
			
		||||
        "version": inconfig['version'],
 | 
			
		||||
        "resource_path": reverse_domain(inconfig['url']).replace('.', '/'),
 | 
			
		||||
@ -203,6 +224,7 @@ def heckimp(args: Sequence[str]):
 | 
			
		||||
        pprint.pprint(derivedconfig)
 | 
			
		||||
        return 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    # visit each file in the source tree,
 | 
			
		||||
    files = list(sourceroot.rglob('*'))
 | 
			
		||||
 | 
			
		||||
@ -279,6 +301,14 @@ def heckimp(args: Sequence[str]):
 | 
			
		||||
                    inf = outpath.read_text().split('\n')
 | 
			
		||||
                    outpath.write_text(inf[0]+('\n'.join(sorted(inf[1:], key=lambda d: d.strip()))))
 | 
			
		||||
 | 
			
		||||
    # post process patches
 | 
			
		||||
    # copy files:
 | 
			
		||||
    if 'files' in inconfig:
 | 
			
		||||
        for f in inconfig['files']:
 | 
			
		||||
            logger.info(f"Adding package-custom files: {f} -> {inconfig['files'][f]}")
 | 
			
		||||
            fpath = find_file(f, searchpaths)
 | 
			
		||||
            shutil.copy(str(fpath), os.path.join(derivedconfig['outtree'], inconfig['files'][f]))
 | 
			
		||||
 | 
			
		||||
    if not pargs.nogit:
 | 
			
		||||
        os.chdir(derivedconfig['outtree'])
 | 
			
		||||
        os.system('git init .')
 | 
			
		||||
 | 
			
		||||
@ -58,14 +58,19 @@ CONTENTS_REGEXP: List[Replacement]  = [
 | 
			
		||||
    ## Resource paths
 | 
			
		||||
    R(re.compile(r"(.*)/org/gimp/(.*)"), r'\1{resource_path}\2'),
 | 
			
		||||
 | 
			
		||||
    ## URLs and things # FIXME we need to respect *some* of the original URLs, we'll take the time to track down those
 | 
			
		||||
    ## and make exceptions later but for now we'll do a big replace. Stuff is mostly in the dialogs, just grep for
 | 
			
		||||
    ## the .org domain in there and we can do a great deal to fix it.
 | 
			
		||||
    ## URLs and things
 | 
			
		||||
    # we also need to make sure we're directing people to the original docs, but also making sure they don't bother
 | 
			
		||||
    # their bug tracker, and also allow the user to replace the various kinds of urls (docs, subpaths like bugs, etc)
 | 
			
		||||
    R(re.compile(r"(.*)https?://www.gimp.org/tutorials(.*)"), r'\1{tutorialurl}\2'),
 | 
			
		||||
    R(re.compile(r"(.*)https?://docs.gimp.org/(.*)"), r'\1{docsurl}\2'),
 | 
			
		||||
    R(re.compile(r"(.*)https?://www.gimp.org/develop(.*)"), r'\1{contriburl}\2'),
 | 
			
		||||
    R(re.compile(r"(.*)https?://www.gimp.org/donating(.*)"), r'\1{donateurl}\2'),
 | 
			
		||||
 | 
			
		||||
    # catchall urls
 | 
			
		||||
    R(re.compile(r"(.*)https?://www.gimp.org(.*)"), r'\1{baseurl}\2'),
 | 
			
		||||
    R(re.compile(r"(.*[ \t\"])(www.)?gimp.org(.*)"), r'\1{baseurl}\3'),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ## general replacements
 | 
			
		||||
    R(re.compile(r"(.*)gimp(.*)"), r'\1{filename}\2'),
 | 
			
		||||
    R(re.compile(r"(.*)GIMP(.*)"), r'\1{ufilename}\2'),
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user