Python Forum
Running Python Packages - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Running Python Packages (/thread-24014.html)

Pages: 1 2


Running Python Packages - mojobadshah - Jan-27-2020

I wanted brief insight into old font types. I decided to make this a primary lesson in Python programming. I have Python 3.8.1 installed on my desktop. I tested demos and they work. A python package called AFDKO contains typography related utilities. I ran both the setup.py executable from this AFDKO package and proceeded to run another the AFDKO executable. The latter contains demo type1 input and output files (the latter output file I removed for diagnostic purposes). I am not seeing any results. What am I missing?


RE: Running Python Packages - jefsummers - Jan-27-2020

Would need to see your code, but will take a stab at it. When you removed the output file, did you then include print statements to display your results?


RE: Running Python Packages - mojobadshah - Jan-28-2020

(Jan-27-2020, 08:55 PM)jefsummers Wrote: Would need to see your code, but will take a stab at it. When you removed the output file, did you then include print statements to display your results?

If the afdko package comes with a setup.py file and I initiate it is this install still needed for Win OS: afdko (also this .bat file doesn't appear to be in the afdko package folder). All the code for this is in that afdko folder. These are the import files listed directly related to type1_test.py:

Quote:import pytest
import subprocess

from runner import main as runner
from differ import main as differ
from test_utils import get_expected_path

TOOL = 'type1'

I'm not clear on why these afdko's would require print statements. They look to be already coded to efficiency.


RE: Running Python Packages - jefsummers - Jan-28-2020

How do you expect it to display your results?
You are not including enough code or information to be able to help


RE: Running Python Packages - mojobadshah - Jan-29-2020

(Jan-28-2020, 08:35 PM)jefsummers Wrote: How do you expect it to display your results?
You are not including enough code or information to be able to help

Here's the afdko source code specific Type1.py executable?

import pytest
import subprocess

from runner import main as runner
from differ import main as differ
from test_utils import get_expected_path

TOOL = 'type1'


# -----
# Tests
# -----

@pytest.mark.parametrize('arg', ['-h'])
def test_exit_known_option(arg):
    assert subprocess.call([TOOL, arg]) == 0


@pytest.mark.parametrize('arg', ['-v', '-u'])
def test_exit_unknown_option(arg):
    assert subprocess.call([TOOL, arg]) == 1


def test_run_on_txt_data():
    actual_path = runner(['-t', TOOL, '-s', '-f', 'type1.txt'])
    expected_path = get_expected_path('type1.pfa')
    assert differ([expected_path, actual_path])
Does this help?


RE: Running Python Packages - jefsummers - Jan-29-2020

You define 3 functions but don't call any of them.


RE: Running Python Packages - mojobadshah - Jan-30-2020

(Jan-29-2020, 07:32 PM)mojobadshah Wrote:
(Jan-28-2020, 08:35 PM)jefsummers Wrote: How do you expect it to display your results?
You are not including enough code or information to be able to help

Here's the afdko source code specific Type1.py executable?

import pytest
import subprocess

from runner import main as runner
from differ import main as differ
from test_utils import get_expected_path

TOOL = 'type1'


# -----
# Tests
# -----

@pytest.mark.parametrize('arg', ['-h'])
def test_exit_known_option(arg):
    assert subprocess.call([TOOL, arg]) == 0


@pytest.mark.parametrize('arg', ['-v', '-u'])
def test_exit_unknown_option(arg):
    assert subprocess.call([TOOL, arg]) == 1


def test_run_on_txt_data():
    actual_path = runner(['-t', TOOL, '-s', '-f', 'type1.txt'])
    expected_path = get_expected_path('type1.pfa')
    assert differ([expected_path, actual_path])
Does this help?

2 functions here are defined as arguments. Is the type1_test here telling me I have to set and call a parameter relative to one of the ids variable '-h' '-v' '-u' and there are no arguments represented apparent in the last function, so would the call function require a path similar to the first two functions in respects to variables '-t' '-s' '-f' and is this last function the only one that needs to be scripted to print?


RE: Running Python Packages - jefsummers - Jan-30-2020

Let's go through your code.
You do some imports
You define the variable TOOL to be a string with a value of 'type1'
You define 3 functions, two with decorators.
The functions are defined, but never called.
The only action your program does, after imports, is assign a string to a variable.


RE: Running Python Packages - mojobadshah - Jan-30-2020

(Jan-30-2020, 12:37 PM)jefsummers Wrote: Let's go through your code.
You do some imports
You define the variable TOOL to be a string with a value of 'type1'
You define 3 functions, two with decorators.
The functions are defined, but never called.
The only action your program does, after imports, is assign a string to a variable.

So, the imports are obvious. The variable is obvious - points to a host of postscript utilities. Presumably, -s is one of the decorators you're referencing, otherwise I'm not clear on what constitutes as a decorator or how these would relate to the 3 functions which are also obvious. I tried adding this call function:

print(TOOL)

But saw no output.


RE: Running Python Packages - jefsummers - Jan-30-2020

In line 9 you added print(TOOL)?
I don't have the libraries you are importing, but print(TOOL) should print 'type1'