4
4
import sys
5
5
import argparse
6
6
from logging import Logger , basicConfig , getLogger
7
- from os import getenv , environ
7
+ from os import getenv , environ , pathsep
8
8
from pathlib import Path
9
9
from typing import List , Set , Optional
10
10
@@ -18,11 +18,8 @@ class Expander:
18
18
19
19
include_guard = re .compile ('#.*ATCODER_[A-Z_]*_HPP' )
20
20
21
- def __init__ (self , lib_paths : List [Path ] = None ):
22
- if lib_paths :
23
- self .lib_paths = lib_paths
24
- else :
25
- self .lib_paths = [Path .cwd ()]
21
+ def __init__ (self , lib_paths : List [Path ]):
22
+ self .lib_paths = lib_paths
26
23
27
24
included = set () # type: Set[str]
28
25
@@ -84,13 +81,14 @@ def expand(self, source: str) -> str:
84
81
parser .add_argument ('--lib' , help = 'Path to Atcoder Library' )
85
82
opts = parser .parse_args ()
86
83
87
- lib_path = Path . cwd ()
84
+ lib_paths = []
88
85
if opts .lib :
89
- lib_path = Path (opts .lib )
90
- elif 'CPLUS_INCLUDE_PATH' in environ :
91
- lib_path = Path (environ ['CPLUS_INCLUDE_PATH' ])
92
-
93
- expander = Expander ([lib_path ])
86
+ lib_paths .append (Path (opts .lib ))
87
+ if 'CPLUS_INCLUDE_PATH' in environ :
88
+ lib_paths .extend (
89
+ map (Path , filter (None , environ ['CPLUS_INCLUDE_PATH' ].split (pathsep ))))
90
+ lib_paths .append (Path .cwd ())
91
+ expander = Expander (lib_paths )
94
92
source = open (opts .source ).read ()
95
93
output = expander .expand (source )
96
94
0 commit comments