• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

New py_tools repo

Coffee is slow to kick in this morning. I can run the README commands in idle but can't seem to get the tests to run with pytest or py.test. I'm pretty sure it's operator error but I'm in the main ehex directory pulled from github. Also tried from the tests directory, the ehex directory, and a virtualenv.

Since I'm a virutalenv newb, how do I test your code without installing it?

This looks like a path issue. I'll take a look. In my defence, nosestests ran clean :)
 
This looks like a path issue. I'll take a look. In my defence, nosestests ran clean :)

Fixed. pytest changes to the tests directory and hence doesn't see the module directory. I've added a path insert to test_ehex.py; you could also run python -m pytest (which doesn't change to the tests directory) and not need the path insert.

Code:
$ py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.5 -- py-1.4.32 -- pytest-2.7.0
rootdir: /home/arthur/Documents/tmp/ehex, inifile: 
collected 16 items 

tests/test_ehex.py ................

========================== 16 passed in 0.05 seconds ===========================
 
Now ehex passes for me:

Code:
=== test session starts ====
platform linux -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0

Code:
=== test session starts ====
platform linux2 -- Python 2.6.6 -- pytest-2.3.5
 
Last edited:
Any objections if I merge py_tools branches "more_skill_options"?

My next fun will be using pymongo to pull Dragons out and turn them into characters. Need to move the character.display() to a presentation class of some sort.

Addendum: Removed dragon_to_char from merge options. It worked the other day but not now.
 
Last edited:
Merged more_skill_options. Deleted the old unicode branch, thought I already had. dragon_to_char needs some time when I'm awake. Maybe later this evening.
 
I had planned to be more active on this, but I'm not able to work from a desk at the moment due to a long running knee injury. I have a laptop, but find coding from the sofa the way I have things set up with my knees up really awkward.

Simon Hibbs
 
I had planned to be more active on this, but I'm not able to work from a desk at the moment due to a long running knee injury. I have a laptop, but find coding from the sofa the way I have things set up with my knees up really awkward.

Simon Hibbs

Quit chasing young women. :P

No worries mate. I picked up a couple smaller white boards. Instead of putting them on the wall I sit with them around the house and map out plans for classes and inheritance. Helps me a lot as I'm still trying to really get this stuff.

Take the time to do something working at a desk meant you didn't have time for. I look forward to your contributions!
 
Last edited:
My task for the day is to fix and merge dragon_to_char branch. The main difference is that it creates the character.display() method and uses that vice __str__. This lets it print UTF-8 character names.

Once that's wrapped up I can look at more tests, work ehex into the mix, and see what else needs doing. I've also started looking at how to wrap this up as a package. Mostly as a mental exercise right now since we need to figure out a better project name than "py_tools". Not sure that would get us a lot of attention on PyPI. :)

Addendum: Harumph. Or I can be honest with myself and admit that I rolled a bunch of different things into one too-big change. Off to break things up and merge them in a bit at a time.
 
Last edited:
Hopefully spending my "free time" this morning going over git diff's and doing incremental commits will teach me better discipline.

Hopefully...

Merged in the dragons_to_char stuff. Major changes:

The Character class uses display() vice __str__. This allows UTF-8 in Py2.

character_tools:
set_name() returns UTF-8 compatible name.
show_upp() can take a string, list, or dict,returns string.
set_skills() can take a skill file from the data directory. See data/spacer_skills.txt for an example.

In bin there are some files with "dragon" in the name. These are things I'm using to pull from MongoDB. Mostly as examples. Used them to write up a combined arms team in atpollards's game.
 
Last edited:
I've uploaded ehex to Pypi - it should be installable with pip.

Installed, uninstalled, reinstalled with pip3/python 3.6.2. Went in and came out cleanly.

Ran some of the doctests fine.

Ran pytest under py3 and py.test under py2 fine.

Only real question is the "from ehex.ehex import ehex". How hard would it be to collapse that? I don't know module structure that well yet.
 
My plan (and I do have one):

I've been wanting to get back into MongoDB for a while and will be in the next M101P on-line class for Python developers.

My real goal is to have a tool that lets me track characters for my books and games. There are lots of paper scraps with UPPs here and physical appearance elsewhere. I want to put those together into an extensible datastore. That's the itch I'm trying to scratch.

Since I've been a recipient of a lot of open source code I plan on keeping mine open and free as well. The potential for a "product" is there but I'm not sure there's a huge market and I am sure my skills need some work.

To keep my learning curve manageable I'm going to stick with what the class uses during class, and that's Python 3, bottle, and MongoDB 3.4. After class I'll see where I want to go and what I want to do.

I appreciate those of you contributing code to the community. In a couple weeks I'll be trying to learn MongoDB while also writing my next book. I expect to have no free time and even fewer brain cells until January. However, the end state should be useful.
 
Installed, uninstalled, reinstalled with pip3/python 3.6.2. Went in and came out cleanly.

Ran some of the doctests fine.

Ran pytest under py3 and py.test under py2 fine.

Only real question is the "from ehex.ehex import ehex". How hard would it be to collapse that? I don't know module structure that well yet.

I've done this in the "single-file" branch in the repo. Importing is now "from ehex import ehex".

This is a substantial change to the interface to the module, and I don't think I can maintain backward compatibility. When it comes to uploading this version to PyPi, should it be an entirely new package (e.g. ehex2) or a version bump?
 
I've done this in the "single-file" branch in the repo. Importing is now "from ehex import ehex".

This is a substantial change to the interface to the module, and I don't think I can maintain backward compatibility. When it comes to uploading this version to PyPi, should it be an entirely new package (e.g. ehex2) or a version bump?

I won't represent myself as the most experienced so take my thoughts as if they are from a junior coder. Which they are. :D

I'd say major version bump assuming semver style numbering. Much cleaner in the long run; we can just let the old stuff die off.
 
I won't represent myself as the most experienced so take my thoughts as if they are from a junior coder. Which they are. :D

I'd say major version bump assuming semver style numbering. Much cleaner in the long run; we can just let the old stuff die off.

semver is what I prefer - I'd make an entirely new package if ehex was in wide use. I don't think that's going to be an issue.

This will bump from v0.1.1 to v1.0.0 - we have a release :)

I'll make the change and merge single-file to master tomorrow. I'll post in a fresh thread to help make sure any users not following this thread are aware of the change.
 
Added a function to build skill array options from a file.

The logic is pretty simple, the input file looks like this:

Code:
2 Admin
1 Blade
1 Bribery
2 Computer
2 Electronic
4 Engineering
2 GunCbt

The first "thing" is converted to an Int and must be > 0. Everything else is a string at added to a list that many times. When I build NPCs I want a skill list that weights proper skills; Army troopers get more chances for GunCbt and Navy pukes get more VaccSuit chances. Using a file like this makes it easy for a non-geek to create their own files. No JSON or YAML needed.
 
I'm learning Python for work, so expect some work from me to end up in your little repo.
 
I'm learning Python for work, so expect some work from me to end up in your little repo.

Just watch if you're learning Python 2 or 3. There are some small but niggling differences. Code *can* be made to work in both but sometimes it's a pain.
 
Back
Top