Content-Length: 234567 | pFad | http://github.com/bulletmark/libinput-gestures/commit/71f3787c7b02b19f431bc52f078127c1c4670cdb

51 Improve implementation of unexpand_user() · bulletmark/libinput-gestures@71f3787 · GitHub
Skip to content

Commit

Permalink
Improve implementation of unexpand_user()
Browse files Browse the repository at this point in the history
  • Loading branch information
bulletmark committed Sep 17, 2022
1 parent 269be4d commit 71f3787
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libinput-gestures
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ session_locked = False

PROGPATH = Path(sys.argv[0])
PROGNAME = PROGPATH.stem
HOME = Path('~').expanduser()

# Conf file containing gesture commands.
# Search first for user file then system file.
Expand Down Expand Up @@ -210,7 +211,7 @@ def add_internal_command(cls):
class ArgumentParser(argparse.ArgumentParser):
'Custom ArgumentParser to return error text'
def error(self, msg):
raise(Exception(msg))
raise Exception(msg)

@add_internal_command
class COMMAND_internal(COMMAND):
Expand Down Expand Up @@ -606,13 +607,12 @@ def get_conf(conffile, confname):

def unexpanduser(cfile):
'Return absolute path name, with $HOME replaced by ~'
relslash = Path(os.path.abspath(str(cfile)))
try:
relhome = relslash.relative_to(os.getenv('HOME'))
except (ValueError, TypeError):
relhome = None
cfile_abs = cfile.resolve()

if cfile_abs.parts[:len(HOME.parts)] != HOME.parts:
return str(cfile_abs)

return ('~/' + str(relhome)) if relhome else str(relslash)
return str(Path('~', *cfile_abs.parts[len(HOME.parts):]))

# Search for configuration file. Use file given as command line
# argument, else look for file in search dir order.
Expand Down

0 comments on commit 71f3787

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/bulletmark/libinput-gestures/commit/71f3787c7b02b19f431bc52f078127c1c4670cdb

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy