Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-Goel-04 committed Sep 6, 2023
1 parent 6787555 commit 7c84926
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions capa/render/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
import io
import sys
import gzip
import json
from typing import Dict, Union, Iterator
Expand Down Expand Up @@ -59,8 +60,11 @@ def capability_rules(doc: rd.ResultDocument) -> Iterator[rd.RuleMatches]:


def load_rules_prevalence() -> Dict[str, str]:
CD = Path(__file__).resolve().parent.parent.parent
file = CD / "assets" / "rules_prevalence.json.gz"
if hasattr(sys, "frozen") and hasattr(sys, "_MEIPASS"):
file = Path(sys._MEIPASS) / "assets" / "rules_prevalence.json.gz" # type: ignore
else:
CD = Path(__file__).resolve().parent.parent.parent
file = CD / "assets" / "rules_prevalence.json.gz"
if not file.exists():
raise FileNotFoundError(f"File '{file}' not found.")
try:
Expand Down

0 comments on commit 7c84926

Please sign in to comment.