diff options
| author | thomas grothe <grothe.tr@gmail.com> | 2023-11-30 12:14:07 -0600 |
|---|---|---|
| committer | thomas grothe <grothe.tr@gmail.com> | 2023-11-30 12:14:07 -0600 |
| commit | 66a95f2294c4965850b7bc70dfa497f65ebfab7f (patch) | |
| tree | 76af86281d70d4bd0b37471feb01d3f2fe89c593 /wow2.py | |
| parent | c88bf4ed44f3366275034360101d64a4c060b410 (diff) | |
grabbing a random 7 lines
Diffstat (limited to 'wow2.py')
| -rwxr-xr-x | wow2.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -20,10 +20,10 @@ def attemptReadSampleFile(filepath): ftype = filetype.guess(filepath) if v: print('filetype: {}'.format(str(ftype))) if ftype != None: - if ftype.extension in ['py', 'c', 'cc', 'h', 'hh', 'java', 'rst', 'css', 'html', 'htm', 'js', 'php']: #don't want code in the sample data + if ftype.extension in ['py', 'c', 'cc', 'h', 'hh', 'java', 'rst', 'css', 'html', 'htm', 'js', 'php', 'sh']: #don't want code in the sample data if v: print('this file is code') return None - if ftype.extension == 'odt': + if ftype.extension == 'odt' and filepath[len(filepath)-1] != '#': #openoffice doc and not a lock file subproc = subprocess.run(['odt2txt', filepath], encoding='utf-8', stdout=subprocess.PIPE) return subproc.stdout else: @@ -70,6 +70,12 @@ while t == None: print() print('{} : {}'.format(samplefiles[fi], t)) +lines = t.splitlines() +li = random.randint(0, len(t)) #line index +#ci = random.randint(0, len(t)) #character index +res = '\n'.join(lines[li: li+7]) +print(res) + #for f in samplefiles: # print(f) |
