Python Forum
Running Python Packages
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running Python Packages
#1
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?
Reply
#2
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?
Reply
#3
(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.
Reply
#4
How do you expect it to display your results?
You are not including enough code or information to be able to help
Reply
#5
(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?
Reply
#6
You define 3 functions but don't call any of them.
Reply
#7
(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?
Reply
#8
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.
Reply
#9
(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.
Reply
#10
In line 9 you added print(TOOL)?
I don't have the libraries you are importing, but print(TOOL) should print 'type1'
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020