extract_odf_links: Don't print document-internal links.
This commit is contained in:
		
							parent
							
								
									b4dee2cf9a
								
							
						
					
					
						commit
						385f5a20da
					
				
					 3 changed files with 6 additions and 4 deletions
				
			
		|  | @ -84,7 +84,6 @@ read from stdin because it needs to know document paths to resolve links. | |||
|     return parser.parse_args(arglist) | ||||
| 
 | ||||
| def extract_links(odf_path: Path) -> Iterator[Path]: | ||||
|     odf_root = odf_path.parent.resolve() | ||||
|     with odf_path.open('rb') as odf_file: | ||||
|         odf_doc = odf.opendocument.load(odf_file) | ||||
|     for a_elem in odf_doc.getElementsByType(odf.text.A): | ||||
|  | @ -95,9 +94,12 @@ def extract_links(odf_path: Path) -> Iterator[Path]: | |||
|         if not path.is_absolute(): | ||||
|             path = (odf_path / path).resolve() | ||||
|             try: | ||||
|                 path.relative_to(odf_root) | ||||
|                 path.relative_to(odf_path) | ||||
|             except ValueError: | ||||
|                 logger.warning(f"link {path} is neither absolute nor relative to {odf_path}") | ||||
|                 pass | ||||
|             else: | ||||
|                 # Link points to another document inside the ODF. Skip it. | ||||
|                 continue | ||||
|         yield path | ||||
| 
 | ||||
| def main(arglist: Optional[Sequence[str]]=None, | ||||
|  |  | |||
							
								
								
									
										2
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
										
									
									
									
								
							|  | @ -5,7 +5,7 @@ from setuptools import setup | |||
| setup( | ||||
|     name='conservancy_beancount', | ||||
|     description="Plugin, library, and reports for reading Conservancy's books", | ||||
|     version='1.7.0', | ||||
|     version='1.7.1', | ||||
|     author='Software Freedom Conservancy', | ||||
|     author_email='info@sfconservancy.org', | ||||
|     license='GNU AGPLv3+', | ||||
|  |  | |||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Brett Smith
						Brett Smith