<commit_before># MusicPlayer, https://github.com/albertz/music-player
# Copyright (c) 2013, <NAME>, www.az2000.de
# All rights reserved.
# This code is under the 2-clause BSD license, see License.txt in the root directory of this project.

# Get some native file-id handle which is persistent from file-moves.

import os, sys
import utils

if sys.platform == "darwin" and utils.isPymoduleAvailable("AppKit"):

	import AppKit
	
	def getFileNativeId(filepath):
		if not os.path.isfile(filepath): return None
		filepath = os.path.abspath(filepath)
		filepath = unicode(filepath)
		
		url = AppKit.NSURL.alloc().initFileURLWithPath_(filepath)
		bookmark, _ = url.bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(AppKit.NSURLBookmarkCreationPreferFileIDResolution,None,None,None)
		
		if not bookmark: return None
		bytes = bookmark.bytes().tobytes()		
		return bytes

	def getPathByNativeId(fileid):
		nsdata = AppKit.NSData.alloc().initWithBytes_length_(fileid, len(fileid))
		url, _, _ = AppKit.NSURL.URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(nsdata, AppKit.NSURLBookmarkResolutionWithoutUI, None,None,None)
		
		if not url: return None
		
		return unicode(url.path())

else:
	
	def getFileNativeId(filepath): return None
	def getPathByNativeId(fileid): return None
<commit_msg>fileid: mac: use NSAutoreleasePoolDecorator<commit_after># MusicPlayer, https://github.com/albertz/music-player
# Copyright (c) 2013, <NAME>, www.az2000.de
# All rights reserved.
# This code is under the 2-clause BSD license, see License.txt in the root directory of this project.

# Get some native file-id handle which is persistent from file-moves.

import os, sys
import utils

if sys.platform == "darwin" and utils.isPymoduleAvailable("AppKit"):

	import AppKit
	from utils import NSAutoreleasePoolDecorator
	
	@NSAutoreleasePoolDecorator
	def getFileNativeId(filepath):
		if not os.path.isfile(filepath): return None
		filepath = os.path.abspath(filepath)
		filepath = unicode(filepath)
		
		url = AppKit.NSURL.alloc().initFileURLWithPath_(filepath)
		bookmark, _ = url.bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(AppKit.NSURLBookmarkCreationPreferFileIDResolution,None,None,None)
		
		if not bookmark: return None
		bytes = bookmark.bytes().tobytes()		
		return bytes

	@NSAutoreleasePoolDecorator
	def getPathByNativeId(fileid):
		nsdata = AppKit.NSData.alloc().initWithBytes_length_(fileid, len(fileid))
		url, _, _ = AppKit.NSURL.URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(nsdata, AppKit.NSURLBookmarkResolutionWithoutUI, None,None,None)
		
		if not url: return None
		
		return unicode(url.path())

else:
	
	def getFileNativeId(filepath): return None
	def getPathByNativeId(fileid): return None

{'fraction_non_alphanumeric': 0.08974358974358974, 'fraction_numerical': 0.00641025641025641, 'mean_word_length': 5.73621103117506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6378353', 'n_tokens_mistral': 981, 'n_tokens_neox': 907, 'n_words': 207}