Commit Graph

21 Commits

Author SHA1 Message Date
T. Joseph Carter
ed78e1335a Let's _not_ accidentally commit a __pycache__ 2017-06-24 03:21:21 -07:00
T. Joseph Carter
a9c7b4e24e Document two more test disks
We're using the latest community GSOS release as a convenient example of a
large ProDOS volume with lots of directory structure, forks, and at least a few
files that can be identified by eyeball as having been extracted correctly.

Then I went looking for something DOS 3.3 with T type files on the disk to
verify those were being extracted correctly.  Randomly stumbled across The
Correspondent 4.4 which has them, but also had some surprises for us.  It
crashed cppo!  A combination of removing bashbyter functions and ensuring a
variable gets initialized caused cppo to be able to cat and dump it.  We do
nothing special about filenames made up entirely of control characters,
however, so they'll print incorrectly and extract as non-printable characters
in your filesystem.  It's legal (if crazy) on most UNIX filesystems.  I have
_no idea_ if or how to handle these things on macOS or Windows.
2017-06-24 03:11:26 -07:00
T. Joseph Carter
5266d532fc Make the editorconfig line limit 79 globally 2017-06-24 03:08:08 -07:00
T. Joseph Carter
79719bb5e0 Change how case folding is done
The old way involved a lot more sequence duplication.  Now just turn the
bytes object into a mutable bytearray, iterate through the mask and
change what we need, then change it back.
2017-06-22 04:37:34 -07:00
T. Joseph Carter
3ebf568a6f More syntax cleanups
A few clumsy if statements got rewritten with truth tables to verify
that the somewhat simplified conditions still evaluated the same.  Other
changes are mostly cosmetic.
2017-06-22 04:17:23 -07:00
T. Joseph Carter
e305008645 unStudlyCaps globals, make bools actually boolean 2017-06-22 04:05:36 -07:00
T. Joseph Carter
3a3531514b Protect main program with __main__ test
Originally cppo was written as a shell script and was never intended to
be a library of functions to be used by anyone else.  Single-file Python
modules are often written to be run as standalone programs either to do
what they do from the command line or for testing purposes.

Theoretically you do this if your code provides useful stuff for other
programs to use, and it's hard to argue that cppo does that yet, but it
is intended to do so in the future.  Let's start working toward that.
2017-06-22 01:59:07 -07:00
T. Joseph Carter
1d1eed33d2 Some diff reduction and renamed variables
A few of my local copies of cppo have some/most of the code reformatted
in a more "pythonic" coding style.  I still use hard tabs for
indentation because even us diehard console-using developers have
editors that can have whatever tabstop we want on a per-file basis, and
we have editorconfig.  It's 2017, get with the times, even for a program
made for accessing files for a 1977 computer!  ;)  No functional changes
here, save for an if statement processing extensions replaces multiple
conditionals with an if x in tuple construct.
2017-06-22 01:33:40 -07:00
T. Joseph Carter
ffbdbc4823 Add linewrap to editorconfig, doc for custom types 2017-06-21 22:47:20 -07:00
T. Joseph Carter
cea7af7bde Add a note about the disks I'm testing with 2017-06-21 22:24:09 -07:00
T. Joseph Carter
3129db5989 Remove a couple needless slyce's 2017-06-21 22:23:39 -07:00
T. Joseph Carter
a496c6bc0f Reformat arg parsing, add sli() function
Python's native sequence slicing method calls for start with optional
stop and step.  This is sometimes exactly what you want, but especially
when parsing binary files, you're gonna want start/length instead.  If
start was an expression, messy.

In cppo, there's a function slyce that returns a sliced sequence using
start/length/step metrics, and this is used exclusively for slicing
sequences.  Except sometimes you really want Python's start/stop...

I figure: Let's do it Python's way with the slicing syntax, but instead
of seq[start:start+length], you can use sli(): seq[sli(start,length)].
It's not currently used that way, but it now can be.  :)
2017-06-21 06:20:46 -07:00
T. Joseph Carter
795694dbb2 Add to_sys_name() to replace the win32 tests
A holdover from DOS 8.3 filenames, files on Windows cannot end with a
dot.  We append a - to such names on Windows platforms in all
operations, which should solve the problem, but we'd just duplicated
that code about a dozen times.  No need, do it once and we can add
whatever filesystem rules for the host system we need to in one spot.
2017-06-21 05:50:22 -07:00
T. Joseph Carter
54c91f70da Improve arg tests, optimize filename splitting
Lots of places want to check the extension, let's extract that just
once, and save the intermediate products so we can reuse those too.
2017-06-21 05:41:29 -07:00
T. Joseph Carter
d94b45dbcc Fix some "else: pass" blocks for debug prints 2017-06-20 19:49:40 -07:00
T. Joseph Carter
567f1f2a8b Make cppo require python3 2017-06-20 19:48:22 -07:00
T. Joseph Carter
8254fd886d Remove unused get_object_names() 2017-06-20 19:47:06 -07:00
T. Joseph Carter
66df732b6e Remove unused shift() 2017-06-20 19:46:28 -07:00
T. Joseph Carter
7b71f597fc Remove unused s() 2017-06-20 19:45:43 -07:00
T. Joseph Carter
3e816f8299 Fix imports 2017-06-20 19:43:29 -07:00
T. Joseph Carter
fb07295e6c One of many versions of cppo I've got around here
This one's missing a lot of the cleanups I've done to the others (it
isn't even python3), but it has the debug print statements and the
formatting is generally pretty good.  I'll go through my local trees and
begin applying some fixes to this code in various repositories and we'll
see if we can't begin refactoring it completely.
2017-06-20 19:27:38 -07:00