line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of App-PythonToPerl |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2023 by Auto-Parallel Technologies, Inc. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
11
|
|
|
|
|
|
|
# ABSTRACT: translates Python source code into Perl source code |
12
|
|
|
|
|
|
|
#use RPerl; |
13
|
|
|
|
|
|
|
package App::PythonToPerl; |
14
|
1
|
|
|
1
|
|
573
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
15
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
44
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.021_000; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
19
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
20
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
21
|
|
|
|
|
|
|
## no critic qw(ProhibitConstantPragma ProhibitMagicNumbers) # USER DEFAULT 3: allow constants |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# [[[ EXPORTS ]]] |
24
|
|
|
|
|
|
|
#use RPerl::Exporter qw(import); |
25
|
1
|
|
|
1
|
|
5
|
use Exporter qw(import); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
40
|
|
26
|
|
|
|
|
|
|
our @EXPORT = qw(python_file_to_perl_files__follow_includes python_files_to_perl_files); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# [[[ INCLUDES ]]] |
29
|
1
|
|
|
1
|
|
21
|
use Perl::Types; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
350
|
|
30
|
1
|
|
|
1
|
|
8
|
use OpenAI::API; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
165
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# [[[ CONSTANTS ]]] |
33
|
|
|
|
|
|
|
# ... |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# [[[ SUBROUTINES ]]] |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# APPYPL01x |
38
|
|
|
|
|
|
|
sub python_files_to_perl_files { |
39
|
|
|
|
|
|
|
# translate multiple directoreis and files of Python source code into Perl, and save the new Perl files |
40
|
0
|
|
|
0
|
0
|
|
{ my string::arrayref $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
( my OpenAI::API $openai, |
42
|
|
|
|
|
|
|
my string::arrayref $python_file_paths, |
43
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
44
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
45
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
46
|
|
|
|
|
|
|
) = @ARG; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my string::arrayref $perl_file_paths = []; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# NEED CODE |
51
|
|
|
|
|
|
|
# NEED CODE |
52
|
|
|
|
|
|
|
# NEED CODE |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $perl_file_paths; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# APPYPL00x |
59
|
|
|
|
|
|
|
sub python_file_to_perl_files__follow_includes { |
60
|
|
|
|
|
|
|
# translate a file of Python source code into Perl, and save the new Perl file; follow all includes & recurse |
61
|
0
|
|
|
0
|
0
|
|
{ my string::arrayref $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
( my OpenAI::API $openai, |
63
|
|
|
|
|
|
|
my string $python_file_path, |
64
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
65
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
66
|
|
|
|
|
|
|
# NEED OTHER ARGS? |
67
|
|
|
|
|
|
|
) = @ARG; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my string::arrayref $perl_file_paths = []; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# NEED CODE |
72
|
|
|
|
|
|
|
# NEED CODE |
73
|
|
|
|
|
|
|
# NEED CODE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# NEED ENABLE |
76
|
|
|
|
|
|
|
# my string::arrayref $python_includes_file_names = []; |
77
|
|
|
|
|
|
|
# |
78
|
|
|
|
|
|
|
# # convert Python include source code to Python file name |
79
|
|
|
|
|
|
|
# foreach my string $python_include (@{$python_includes}) { |
80
|
|
|
|
|
|
|
# push @{$python_includes_file_names}, python_include_to_file_name($python_include); |
81
|
|
|
|
|
|
|
# } |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# # for all includes, recursively translate all Python files to Perl |
84
|
|
|
|
|
|
|
# my string::arrayref $perl_includes_file_names = []; |
85
|
|
|
|
|
|
|
# foreach my string $python_include_file_name (@{$python_includes_file_names}) { |
86
|
|
|
|
|
|
|
# push @{$perl_includes_file_names}, python_file_to_perl_file($openai, $python_include_file_name); |
87
|
|
|
|
|
|
|
# } |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $perl_file_paths; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; # end of package |