snose

Check-in [cf115f6116]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improve regex for filename matching and exit properly if none found
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: cf115f6116dfe1b47d24741253f7d43fce376965d9fcb73b1bd7e78065713d86
User & Date: simon 2018-10-13 12:26:03
Context
2018-10-18
19:32
Tweak command line args more to suit --file check-in: bdaac3057a user: simon tags: master, trunk
2018-10-13
12:26
Improve regex for filename matching and exit properly if none found check-in: cf115f6116 user: simon tags: master, trunk
12:03
Fixes from 1fe8adea90

Blindly copy/pasted. Some were name not filename check-in: 2f57297d12 user: simon tags: master, trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to snose.py.

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    else:
        #Write file
        #If no filename supplied try to figure out from first three lines of file itself
        if filename is None:
            firstlines = remote[0]['content'].splitlines()[:3]
            for line in firstlines:
                try:
                    filename = re.search(r'file:(\S+)\s', line).group(1)
                except IndexError:
                    pass
                except AttributeError:
                    pass
            if filename is None:
                print("Failed to identify filename within note, please provide on command line")
                exit
        filename = os.path.expanduser(filename)
        try:
            if sys.version_info < (3, 0):
                with open(filename, 'w') as f:
                    f.write(remote[0]['content'].encode("utf-8"))
            else:
                with open(filename, 'w', encoding="utf-8") as f:







|






|







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    else:
        #Write file
        #If no filename supplied try to figure out from first three lines of file itself
        if filename is None:
            firstlines = remote[0]['content'].splitlines()[:3]
            for line in firstlines:
                try:
                    filename = re.search(r'file:(\S+)', line).group(1)
                except IndexError:
                    pass
                except AttributeError:
                    pass
            if filename is None:
                print("Failed to identify filename within note, please provide on command line")
                sys.exit()
        filename = os.path.expanduser(filename)
        try:
            if sys.version_info < (3, 0):
                with open(filename, 'w') as f:
                    f.write(remote[0]['content'].encode("utf-8"))
            else:
                with open(filename, 'w', encoding="utf-8") as f: